msbuild - VisualStudio.com 无法在构建期间加载临时 UWP 证书

标签 msbuild visual-studio-2015 win-universal-app azure-devops build-server

我设置了 Visual Studio Team Service 帐户来克隆我的私有(private) GitHub 存储库,并在排队构建时随时构建 Windows UWP 应用程序。克隆工作没有任何问题;除一个项目外,每个项目 (6) 的编译均有效。 Windows UWP 应用项目。

当构建服务器编译应用程序时,我收到以下警告:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(1778,5): Warning APPX0104: Certificate file 'myapp_TemporaryKey.pfx' not found.

2>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(1778,5): warning APPX0104: Certificate file 'myapp_TemporaryKey.pfx' not found. [C:\a\1\s\Source\Applications\myapp.WindowsUWP\myapp.csproj]

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(1778,5): Warning APPX0102: A certificate with thumbprint '58F2EA544193F6FC9F2737135570555B388E58D8' that is specified in the project cannot be found in the certificate store. Please specify a valid thumbprint in the project file.

2>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(1778,5): warning APPX0102: A certificate with thumbprint '58F2EA544193F6FC9F2737135570555B388E58D8' that is specified in the project cannot be found in the certificate store. Please specify a valid thumbprint in the project file. [C:\a\1\s\Source\Applications\myapp.WindowsUWP\myapp.csproj]

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(1778,5): Warning APPX0107: The certificate specified is not valid for signing. For more information about valid certificates, see http://go.microsoft.com/fwlink/?LinkID=241478. 2>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(1778,5): warning APPX0107: The certificate specified is not valid for signing. For more information about valid certificates, see http://go.microsoft.com/fwlink/?LinkID=241478. [C:\a\1\s\Source\Applications\myapp.WindowsUWP\myapp.csproj]

这是 6 个要编译的项目中的最后一个。收到警告后,它会继续将所有输出文件复制到最终的/bin 目录。然后,当一切完成后,报告与上面相同的消息,但这次是错误并且构建失败。

_GenerateAppxPackageFile: C:\Program Files (x86)\Windows Kits\10\bin\x64\MakeAppx.exe pack /l /h sha256 /f obj\x86\Debug\package.map.txt /o /p C:\a\1\s\Source\Applications\MyApp.WindowsUWP\AppPackages\MyApp_1.0.0.0_x86_Debug_Test\MyApp_1.0.0.0_x86_Debug.appx
MyApp -> C:\a\1\s\Source\Applications\MyApp.WindowsUWP\AppPackages\MyApp_1.0.0.0_x86_Debug_Test\MyApp_1.0.0.0_x86_Debug.appx C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(2382,5): Error APPX0104: Certificate file 'MyApp_TemporaryKey.pfx' not found. 2>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(2382,5): error APPX0104: Certificate file 'MyApp_TemporaryKey.pfx' not found. [C:\a\1\s\Source\Applications\MyApp.WindowsUWP\MyApp.csproj] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(2382,5): Error APPX0102: A certificate with thumbprint '58F2EA544193F6FC9F2737135570555B388E58D8' that is specified in the project cannot be found in the certificate store. Please specify a valid thumbprint in the project file. 2>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(2382,5): error APPX0102: A certificate with thumbprint '58F2EA544193F6FC9F2737135570555B388E58D8' that is specified in the project cannot be found in the certificate store. Please specify a valid thumbprint in the project file. [C:\a\1\s\Source\Applications\MyApp.WindowsUWP\MyApp.csproj] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(2382,5): Error APPX0107: The certificate specified is not valid for signing. For more information about valid certificates, see http://go.microsoft.com/fwlink/?LinkID=241478. 2>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(2382,5): error APPX0107: The certificate specified is not valid for signing. For more information about valid certificates, see http://go.microsoft.com/fwlink/?LinkID=241478. [C:\a\1\s\Source\Applications\MyApp.WindowsUWP\MyApp.csproj] 2>Done Building Project "C:\a\1\s\Source\Applications\MyApp.WindowsUWP\MyApp.csproj" (default targets) -- FAILED. 1>Done Building Project "C:\a\1\s\Source\MyApp.UWP.sln" (default targets) -- FAILED. Build FAILED. "C:\a\1\s\Source\MyApp.UWP.sln" (default target) (1) ->

如果我只是删除证书(就像我在这个特定错误日志中所做的那样),它会失败,因为找不到它。如果我使用 VS 中的 list 编辑器生成证书并为其分配密码,则构建服务器会失败,因为它不知道密码。所以无论我是否提供临时测试证书,我都无法构建它。

我们应该如何通过 Visual Studio Team Services 构建系统运行 Windows 10 UWP 应用?这是微软已经推广了一段时间的事情,所以我认为这是一件可以做到的事情。我似乎无法实际构建 UWP 项目。

最佳答案

您可以生成无需分配密码的证书。

或者在构建定义中添加 PowerShell 步骤以导入受密码保护的证书。以下是您可以使用的 powershell 脚本:

$pfxpath = 'myapp_TemporaryKey.pfx'
$password = 'yourpassword'

Add-Type -AssemblyName System.Security
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$cert.Import($pfxpath, $password, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]"PersistKeySet")
$store = new-object system.security.cryptography.X509Certificates.X509Store -argumentlist "MY", CurrentUser
$store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]"ReadWrite")
$store.Add($cert)
$store.Close()

请记住将“工作文件夹”设置为放置 pfx 文件的路径。

关于msbuild - VisualStudio.com 无法在构建期间加载临时 UWP 证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33841222/

相关文章:

c# - $(ProjectName) 和 $(TargetName) MSBuild 宏不起作用

c - 在 Visual Studio 中出现错误

visual-studio-2015 - Visual Studio 2015 RTM 中的设备列表中没有显示电话模拟器

command-line - 在命令行上构建 Windows 8 Phone 应用程序

c# - 如何在 .csproj 文件中使用 MSBuild 条件测试编译器指令?

c# - Microsoft.Build.BuildEngine 可以是多线程的吗

C++ std::bind 到 std::function,在 VS2015 中出了什么问题?

cordova - Visual Studio 2015 Apache Cordova 托管 Web 应用程序主屏幕在与现有 Windows 应用商店应用程序关联后变成空白屏幕?

c# - Windows 手机 8.1 : How to add data annotations to enum value types to get the appropriate string

c# - 自定义DatePicker Windows Phone 8.1通用