简体   繁体   English

UWP 项目在 GitHub Actions 上失败,因为证书无效 APPX0107

[英]UWP project failed on GitHub Actions because certificate is invalid APPX0107

ITNOA ITNOA

I have a project in GitHub that have UWP project in here .我在 GitHub 中有一个项目,这里有 UWP 项目。

I want to setup GitHub Actions for this project with this main.yml configuration我想用这个 main.yml 配置为这个项目设置 GitHub Actions

When GitHub Actions want to build my solution with below commands当 GitHub Actions 想要使用以下命令构建我的解决方案时

- name: Library build

  run: |

    cd src

    nuget restore

    msbuild PCLAppConfig.sln /verbosity:normal /t:Rebuild /p:Configuration=Release

I see failed error with below error in UWP building我在 UWP 构建中看到以下错误的失败错误

2020-03-23T13:07:20.1871936Z "D:\a\PCLAppConfig\PCLAppConfig\src\PCLAppConfig.sln" (Rebuild target) (1) ->
2020-03-23T13:07:20.1872322Z "D:\a\PCLAppConfig\PCLAppConfig\src\DemoApp\DemoApp.UWP\DemoApp.UWP.csproj" (Rebuild target) (10) ->
2020-03-23T13:07:20.1872524Z (_GenerateCurrentProjectAppxManifest target) -> 
2020-03-23T13:07:20.1872807Z   C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microsoft.AppXPackage.Targets(2650,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. [D:\a\PCLAppConfig\PCLAppConfig\src\DemoApp\DemoApp.UWP\DemoApp.UWP.csproj]
2020-03-23T13:07:20.1873172Z 
2020-03-23T13:07:20.1873447Z 
2020-03-23T13:07:20.1873657Z "D:\a\PCLAppConfig\PCLAppConfig\src\PCLAppConfig.sln" (Rebuild target) (1) ->
2020-03-23T13:07:20.1873802Z "D:\a\PCLAppConfig\PCLAppConfig\src\DemoApp\DemoApp.UWP\DemoApp.UWP.csproj" (Rebuild target) (10) ->
2020-03-23T13:07:20.1873935Z (_GenerateAppxPackageFile target) -> 
2020-03-23T13:07:20.1874153Z   C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microsoft.AppXPackage.Targets(3402,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. [D:\a\PCLAppConfig\PCLAppConfig\src\DemoApp\DemoApp.UWP\DemoApp.UWP.csproj]
2020-03-23T13:07:20.1874919Z 
2020-03-23T13:07:20.1875022Z     4 Warning(s)
2020-03-23T13:07:20.1875125Z     1 Error(s)
2020-03-23T13:07:20.1875697Z 
2020-03-23T13:07:20.1875988Z Time Elapsed 00:03:28.50
2020-03-23T13:07:20.6575030Z ##[error]Process completed with exit code 1.

the note is if I run msbuild PCLAppConfig.sln /verbosity:normal /t:Rebuild /p:Configuration=Release in local computer, build is successfully and does not have any error, and I can run UWP app locally.请注意,如果我在本地计算机上运行msbuild PCLAppConfig.sln /verbosity:normal /t:Rebuild /p:Configuration=Release ,则构建成功且没有任何错误,我可以在本地运行 UWP 应用程序。

My question is what is my problem?我的问题是我的问题是什么? and how can I resolve this?我该如何解决这个问题?

thanks谢谢

You should set the PackageCertificateKeyFile and sure the file push to the GitHub.您应该设置 PackageCertificateKeyFile 并确保文件推送到 GitHub。 And you should add the password to your pfx file.您应该将密码添加到您的 pfx 文件中。

    /p:PackageCertificateKeyFile=Package_TemporaryKey.pfx /p:PackageCertificatePassword="123"

Please replace the Package_TemporaryKey.pfx and the password.请替换Package_TemporaryKey.pfx和密码。

If you do not want to push the pfx file to GitHub that you can use github secrets如果您不想将 pfx 文件推送到 GitHub,您可以使用github secrets

The first is parse the pfx file as base64 string.首先是将 pfx 文件解析为 base64 字符串。

The second is set the pfx file base64 string to github secrets.第二个是将 pfx 文件 base64 字符串设置为 github secrets。

And then you can use this base64 string before you start build.然后你可以在开始构建之前使用这个 base64 字符串。

Decode the Base64 encoded Pfx
- name: Decode the Pfx
  run: |
    $pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}")
    $currentDirectory = Get-Location
    $certificatePath = Join-Path -Path $currentDirectory -ChildPath $env:Wap_Project_Directory -AdditionalChildPath $env:SigningCertificate
    [IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte)

And you can find my sample code in github你可以在github 中找到我的示例代码

Edit编辑

I read your code and found the DemoApp.UWP_TemporaryKey.pfx and Windows_TemporaryKey.pfx file.我阅读了您的代码并找到了DemoApp.UWP_TemporaryKey.pfxWindows_TemporaryKey.pfx文件。 Because my Internet speed is very poor, and could you clean your code by git clean -xdf and then use commandline to compile in locally?因为我网速很差,能不能先用git clean -xdf清理你的代码,然后用命令git clean -xdf本地编译? Maybe you should explicitly specify which file to use.也许您应该明确指定要使用的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM