dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.21k stars 1.75k forks source link

Android keystore parameter is relative to the project path not the working directory. #22671

Open joshbartley opened 5 months ago

joshbartley commented 5 months ago

Description

The android keystore signing parameters are relative to the project being built and not the working path. If the file is not found, the publish process will continue with a debug signing certificate. This gives the appearance everything is fine until you see a random SHA1 on your google play submission error message. Command line publish docs do not mention this and only was able spot it by enabling -v d which then threw an error that the file was missing.

Steps to Reproduce

  1. Create an android keystore file in the solution root.
  2. dotnet publish src/Mobile.Maui/Mobile.Maui.csproj -c Release -f net8.0-android --no-restore -p:AndroidKeyStore=true -p:AndroidSigningKeyStore=android.keystore -p:AndroidSigningKeyAlias=android_202405 -p:AndroidSigningKeyPass=file:android_key_pass.txt -p:AndroidSigningStorePass=file:android_key_pass.txt
  3. keytool -printcert -jarfile src/Mobile.Maui/bin/Release/net8.0-android/com.*********.mobile-Signed.aab

Now move the keystore file to src/Mobile.Maui/

  1. Create an android keystore file in the solution root.
  2. dotnet publish src/Mobile.Maui/Mobile.Maui.csproj -c Release -f net8.0-android --no-restore -p:AndroidKeyStore=true -p:AndroidSigningKeyStore=android.keystore -p:AndroidSigningKeyAlias=android_202405 -p:AndroidSigningKeyPass=file:android_key_pass.txt -p:AndroidSigningStorePass=file:android_key_pass.txt
  3. keytool -printcert -jarfile src/Mobile.Maui/bin/Release/net8.0-android/com.*********.mobile-Signed.aab

Keytool will print a different sha1. This was done on a Github self-hosted runner.

Link to public reproduction project repository

No response

Version with bug

8.0.40 SR5

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

Now move the keystore file to src/Mobile.Maui/ to the root of the MAUI project not the root of the solution.

Relevant log output

This was only shown and thrown when `-v d` was used.

C:\WINDOWS\ServiceProfiles\NetworkService\AppData\Local\Microsoft\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.95\tools\Xamarin.Android.Common.targets(2409,2): error XA4310: `$(AndroidSigningKeyStore)` file `android.keystore` could not be found. [C:\actions-runner\_work\Mobile.Maui\Mobile.Maui\src\Mobile.Maui\Mobile.Maui.csproj::TargetFramework=net8.0-android]
github-actions[bot] commented 5 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

joshbartley commented 5 months ago

Something else I ran across. I had a build step before the publish step. Removing the build step both provided an error message the keystore wasn't found in the path. The msbuild logs also said that the apk was "Up to date" during publish and may have skipped the signing step.

pMaske commented 3 months ago

I am running into a similar issue. Keystore value passed to AndroidSigningKeyStore is not honored when I pass the parameter to publish command via msbuild.