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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
{
Expand Down
32 changes: 19 additions & 13 deletions src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,9 @@ because xbuild doesn't support framework reference assemblies.
</CreateProperty>

<CreateProperty Value="$(_AppSettingsDirectory)debug.keystore">
<Output TaskParameter="Value" PropertyName="_ApkDebugKeyStore"/>
<Output TaskParameter="Value" PropertyName="_ApkDebugKeyStore"
Condition="'$(_ApkDebugKeyStore)' == ''"
/>
</CreateProperty>

<CreateProperty Value="$(MonoAndroidToolsDirectory)">
Expand Down Expand Up @@ -2455,9 +2457,23 @@ because xbuild doesn't support framework reference assemblies.

<Delete Files="$(_UploadFlagFile)" Condition="Exists ('$(_UploadFlagFile)')" />
</Target>


<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.

>
<AndroidCreateDebugKey
KeyStore="$(_ApkDebugKeyStore)"
KeyAlias="androiddebugkey"
KeyPass="android"
StorePass="android"
ToolPath="$(KeytoolToolPath)"
ToolExe="$(KeytoolToolExe)"
Command="-genkeypair"
/>
</Target>

<Target Name="_ResolveAndroidSigningKey" DependsOnTargets="$(_OnResolveMonoAndroidSdks);_CreateAndroidDebugSigningKey">
<!-- would use a PropertyGroup here but xbuild doesn't support it -->
<CreateProperty Value="$(_ApkDebugKeyStore)" Condition="'$(AndroidKeyStore)'!='True'">
<Output TaskParameter="Value" PropertyName="_ApkKeyStore"/>
Expand All @@ -2484,16 +2500,6 @@ because xbuild doesn't support framework reference assemblies.
<CreateProperty Value="$(AndroidSigningKeyPass)" Condition="'$(AndroidKeyStore)'=='True'">
<Output TaskParameter="Value" PropertyName="_ApkKeyPass"/>
</CreateProperty>

<AndroidCreateDebugKey
KeyStore="$(_ApkKeyStore)"
KeyAlias="$(_ApkKeyAlias)"
KeyPass="$(_ApkKeyPass)"
StorePass="$(_ApkStorePass)"
ToolPath="$(KeytoolToolPath)"
ToolExe="$(KeytoolToolExe)"
Command="-genkeypair"
Condition="'$(AndroidKeyStore)'=='' and !Exists ('$(_ApkKeyStore)')" />

<Delete Files="$(_AndroidDebugKeyStoreFlag)" Condition="'$(AndroidKeyStore)'=='True'" />
<Touch Files="$(_AndroidDebugKeyStoreFlag)" AlwaysCreate="True" Condition="'$(AndroidKeyStore)'!='True'" />
Expand Down