托管代理上的 UWP 证书问题

UWP certificate issue on hosted agents

我正在尝试 运行 使用 Team Foundation Server 和 App Center 构建 UWP,但出现此错误。

 ##[error]C:\Program Files (x86)\Microsoft Visual Studio17\Enterprise\MSBuild.0\Bin\Microsoft.Common.CurrentVersion.targets(3090,5): Error MSB3325: Cannot import the following key file: AppCenterTest.UWP_TemporaryKey.pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_480BF88F6934FA8C

我尝试为 Team Foundation Server 创建一个专用代理,这仅解决了 Team Foundation Server 的问题,因为证书安装在我的专用代理上。但默认情况下,App Center 是 运行 托管代理。

如何解决这个问题?谢谢。

看看下面的声明:

Select the right type of build agent

Choose the type of build agent that you want VSTS to use when it executes the build process. A hosted build agent is deployed with the most common tools and sdks, and it will work for most scenarios, see the Software on the hosted build server article. However, you can create a custom build agent if you need more control over the build steps. You can use the following table to help you make that decision.

注意:如果您计划以 Windows 周年更新 SDK(内部版本 14393)为目标,您将需要设置自定义构建代理,因为托管构建池仅支持 SDK 10586和 10240。有关选择 UWP 版本的更多信息

此外,如果您使用Git存储库,请将项目的证书文件添加到存储库中,以便构建代理可以对appx包进行签名。如果不这样做,Git 存储库将忽略证书文件。要将证书文件添加到存储库,right-click 解决方案资源管理器中的证书文件,然后在快捷菜单中选择将忽略的文件添加到源代码管理命令。

更多详情请参考本教程:Set up automated builds for your UWP app

而不是在 Package.appxmanifest > 打包 > 选择证书中创建测试证书。我在我的 UWP 项目 Properties > Signing > Choose a strong name key file: > New.此步骤解决了我的问题。