From 5b2e0271ad5d6f5089f25822961b05a47847d1f1 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Thu, 4 Jan 2018 22:34:10 +0000 Subject: [PATCH] [Xamarin.Android.Build.Tasks] Always create the debug.keystore (#1148) 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. --- .../Xamarin.Android.Build.Tests/BuildTest.cs | 16 ++++++++++ .../Xamarin.Android.Common.targets | 32 +++++++++++-------- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs index b28d0979a86..8fdd683924d 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs @@ -54,6 +54,22 @@ public void BuildBasicApplicationReleaseFSharp () } } + [Test] + public void CheckKeystoreIsCreated () + { + var proj = new XamarinAndroidApplicationProject () { + IsRelease = true, + }; + using (var b = CreateApkBuilder ("temp/CheckKeystoreIsCreated", false, false)) { + var file = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "debug.keystore"); + var p = new string [] { + $"_ApkDebugKeyStore={file}", + }; + Assert.IsTrue (b.Build (proj, parameters: p), "Build should have succeeded."); + FileAssert.Exists (file, $"{file} should have been created."); + } + } + [Test] public void FSharpAppHasAndroidDefine () { diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets index 0e2068c685c..7a971a52255 100755 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets @@ -727,7 +727,9 @@ because xbuild doesn't support framework reference assemblies. - + @@ -2455,9 +2457,23 @@ because xbuild doesn't support framework reference assemblies. - - + + + + + @@ -2484,16 +2500,6 @@ because xbuild doesn't support framework reference assemblies. - -