Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Xamarin.Android.Build.Tasks] Always create the debug.keystore #1148

Merged
merged 5 commits into from
Jan 4, 2018

Conversation

dellis1972
Copy link
Contributor

@dellis1972 dellis1972 commented Jan 2, 2018

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=61065

If a user sets the $(AndroidKeyStore) to True for a
debug configuration they will get the following error.

[MESSAGE] jarsigner error: java.lang.RuntimeException: keystore load: /Users/$(user)/.local/share/Xamarin/Mono for Android/debug.keystore (No such file or directory)

Note this will only happen if they have NEVER build with
$(AndroidKeyStore) set to False. This is because we
don't always generate the debug.keystore.

So rather than hitting this issue we should always generate the
debug.keystore regardless of what the setting for $(AndroidKeyStore)
is. This commit splits out the keystore generation into its own
target. This target will check the existance of the file and
generate it if required. We also move all the debug key property
values into Properties so that they can be updated in one place.

@dellis1972 dellis1972 added Area: xamarin-android Build Issues building the xamarin-android repo *itself*. do-not-merge PR should not be merged. labels Jan 2, 2018
@dellis1972 dellis1972 changed the title debug.keystore is missing in mac and windows installer jarsigner exited with value: 1 [WIP] [Xamarin.Android.Build.Tasks] Always create the debug.keystore Jan 2, 2018
@dellis1972 dellis1972 removed the do-not-merge PR should not be merged. label Jan 2, 2018
@jonpryor jonpryor added Area: App+Library Build Issues when building Library projects or Application projects. and removed Area: xamarin-android Build Issues building the xamarin-android repo *itself*. labels Jan 2, 2018
@jonpryor
Copy link
Member

jonpryor commented Jan 3, 2018

This PR confuses me.

The original bug is that the Mono.Android.DebugRuntime*.apk shared runtime is signed with the "debug key," which isn't always created. If it hasn't been created, then package installation fails.

Additionally, the shared runtime creation logic within androidtools hardcodes the values used here, e.g. androiddebugkey as the jarsigner key alias.

Using $(_ApkDebugKeyAlias) to store androiddebugkey and then allowing $(_ApkDebugKeyAlias) to be overridden -- as the //CreateProperty/Output[@PropertyName='_ApkDebugKeyAlias']/@Condition supports -- is a recipe for future errors, as some enterprising developer decides to override $(_ApkDebugKeyAlias) within their .csproj and then wonders why things break in wonderful and mysterious ways.

I would prefer that the <AndroidCreateDebugKey/> invocation just hardcoded all the values. It's the "debug" key; we control it.

<Target Name="_ResolveAndroidSigningKey" DependsOnTargets="$(_OnResolveMonoAndroidSdks)">
<Target Name="_CreateAndroidDebugSigningKey"
Condition="!Exists ('$(_ApkDebugKeyStore)')"
DependsOnTargets="$(_OnResolveMonoAndroidSdks)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this DependsOnTargets required? The only caller -- _ResolveAndroidSigningKey -- has $(_OnResolveMonoAndroidSdks) within its DependsOnTargets anyway.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=61065

If a user sets the `$(AndroidKeyStore)` to `True` for a
debug configuration they will get the following error.

	[MESSAGE] jarsigner error: java.lang.RuntimeException: keystore load: /Users/$(user)/.local/share/Xamarin/Mono for Android/debug.keystore (No such file or directory)

Note this will only happen if they have NEVER build with
`$(AndroidKeyStore)` set to `False`. This is because we
don't always generate the `debug.keystore`.

So rather than hitting this issue we should always generate the
`debug.keystore` regardless of what the setting for `$(AndroidKeyStore)`
is. This commit splits out the keystore generation into its own
target. This target will check the existance of the file and
generate it if required. We also move all the debug key property
values into Properties so that they can be updated in one place.
@dellis1972
Copy link
Contributor Author

@jonpryor I removed the properties.. One thing to note.. our assumption that CreateProperty does NOT override command line arguments is find for msbuild but NOT for xbuild. It just happily overwrites the values. So I have had to leave the condition on the _ApkDebugKeyStore CreateProperty call.

@jonpryor jonpryor merged commit 5b2e027 into dotnet:master Jan 4, 2018
@EmilAlipiev
Copy link

Hi, interestingly it also fails if i refer to another keystore file. VS still looking for debug.keystore. please see the forum post more information.

jonpryor added a commit to jonpryor/xamarin-android that referenced this pull request Jan 22, 2021
Fixes: xamarin/monodroid#1147
Fixes: xamarin/monodroid#1150
Fixes: xamarin/monodroid#1123

Changes: xamarin/monodroid@3586135...06e80c5

  * xamarin/monodroid@06e80c567: [tools/msbuild] FastDeploy is not ignoring warnings in output  (dotnet#1151) (dotnet#1152)
  * xamarin/monodroid@1f08686de: [tools/msbuild] <FastDeploy/> Length cannot be less than zero (dotnet#1148)
jonpryor added a commit that referenced this pull request Jan 22, 2021
Fixes: xamarin/monodroid#1123
Fixes: xamarin/monodroid#1147
Fixes: xamarin/monodroid#1150

Changes: xamarin/monodroid@3586135...06e80c5

  * xamarin/monodroid@06e80c567: [tools/msbuild] FastDeploy is not ignoring warnings in output  (#1151) (#1152)
  * xamarin/monodroid@1f08686de: [tools/msbuild] <FastDeploy/> Length cannot be less than zero (#1148)
jonpryor pushed a commit that referenced this pull request Jan 23, 2021
Fixes: xamarin/monodroid#1147

Changes: http://github.com/xamarin/monodroid/compare/27736a7ffc48d606ab45598f761e873f8572f46a...daa2fb6ca52ecfd0884177da5b57501bb4dda3c6

  * xamarin/monodroid@daa2fb6ca: Bump to xamarin/xamarin-analysis@9524531 (#1149)
  * xamarin/monodroid@bca44d592: [tools/msbuild] <FastDeploy/> Length cannot be less than zero (#1148)
  * xamarin/monodroid@2df384fe2: [tools/msbuild] improve XA0010 error message (#1144)
  * xamarin/monodroid@b2da84d5f: [tools/msbuild] remove MSBuild targets related to the Xamarin Inspector (#1143)
@github-actions github-actions bot locked and limited conversation to collaborators Feb 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: App+Library Build Issues when building Library projects or Application projects.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants