.NET MAUI Android在GitHub Actions上构建失败,错误代码为1。

huangapple go评论862阅读模式
英文:

.NET MAUI Android Build Fails on GitHub Actions with jarsigner.exe Exited with Code 1

问题

摘要:

我正在尝试使用GitHub Actions构建和签名一个.NET MAUI Android应用程序。虽然在我的本地机器上一切正常,GitHub Actions工作流程在签名阶段遇到了与jarsigner.exe相关的错误。

问题:

错误信息:

C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows.0.68\tools\Xamarin.Android.Common.targets(2335,2): error MSB6006: "jarsigner.exe" exited with code 1. [D:\a\App.name\App.name\App.name\App.name.csproj::TargetFramework=net7.0-android]

工作流程的最后一部分:

- name: Setup Java
  uses: actions/setup-java@v3
  with:
    distribution: 'microsoft'
    java-version: '17'

- name: Build
  run: dotnet build App.name/App.name.csproj -c Release -f net7.0-android /p:AndroidSigningKeyPass=${{ secrets.KEYSTORE_PASSWORD }} /p:AndroidSigningStorePass=${{ secrets.KEYSTORE_PASSWORD_STORE }} --no-restore

附加信息:

  • 密钥库文件已正确解密,并在GitHub secrets中可用。
  • 使用的Java版本是来自Microsoft分发的17版本。
  • 工作流程中的所有前面的步骤,包括依赖恢复和MAUI工作负载安装,都没有问题。是否有人遇到过类似的问题,或者能够解释在GitHub Actions中出现jarsigner.exe错误的原因?我是否应该共享整个.yaml文件?
英文:

Summary:

I'm attempting to build and sign a .NET MAUI Android app using GitHub Actions. While everything works perfectly on my local machine, and the GitHub Actions workflow runs smoothly up until the signing stage, I encounter an error related to jarsigner.exe during the build process on GitHub Actions.

The problem:

Error message

C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows.0.68\tools\Xamarin.Android.Common.targets(2335,2): error MSB6006: "jarsigner.exe" exited with code 1. [D:\a\App.name\App.name\App.name\App.name.csproj::TargetFramework=net7.0-android]

Last part of the workflow

- name: Setup Java
  uses: actions/setup-java@v3
  with:
    distribution: 'microsoft'
    java-version: '17'

- name: Build
  run: dotnet build App.name/App.name.csproj -c Release -f net7.0-android /p:AndroidSigningKeyPass=${{ secrets.KEYSTORE_PASSWORD }} /p:AndroidSigningStorePass=${{ secrets.KEYSTORE_PASSWORD_STORE }} --no-restore

Additional Information:

  • The keystore file is correctly decrypted and available in the GitHub secrets
  • Actions environment. The Java version being used is 17 from the
  • Microsoft distribution. All preceding steps in the workflow, including dependency restoration and MAUI workload installation, complete without issues. Has anyone encountered a similar issue or can provide insights into what might be causing this error with jarsigner.exe on GitHub Actions?

Should I perhaps share the the entire .yaml file?

答案1

得分: 0

好的,我来为你翻译以下内容:

好的,问题已解决。

在.csproj文件中删除密钥库配置,并将它们添加到命令中使其正常工作。

  run: dotnet build App.name/App.name.csproj -c Release -f net7.0-android /p:AndroidKeyStore=true /p:AndroidSigningKeyStore=${{secrets.KEYSTORE}} /p:AndroidSigningKeyAlias=${{ secrets.KEYSTORE_ALIAS }} /p:AndroidSigningKeyPass=${{ secrets.KEYSTORE_PASSWORD }} /p:AndroidSigningStorePass=${{ secrets.KEYSTORE_PASSWORD }}
--no-restore

编辑:

必须删除/p:AndroidKeyStore=true以避免出现错误。

编辑2:实际上,我重新添加了/p:AndroidKeyStore=true。真正的问题在于我在哪个环境中运行gpg命令以生成密钥库。

英文:

Ok, so I solved it.

Removing the keystore config in the .csproj file and adding them to the command made it worked.

  run: dotnet build App.name/App.name.csproj -c Release -f net7.0-android /p:AndroidKeyStore=true /p:AndroidSigningKeyStore=${{secrets.KEYSTORE}} /p:AndroidSigningKeyAlias=${{ secrets.KEYSTORE_ALIAS }} /p:AndroidSigningKeyPass=${{ secrets.KEYSTORE_PASSWORD }} /p:AndroidSigningStorePass=${{ secrets.KEYSTORE_PASSWORD }}
--no-restore

Edit:

Had to remove /p:AndroidKeyStore=true for it to not throw errors.

Edit 2: Actually I added /p:AndroidKeyStore=true back. The real problem was in wich environment I was running the gpg command for the keystore.

huangapple
  • 本文由 发表于 2023年8月11日 15:22:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76881458.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定