diff --git a/.external b/.external index 13d19cd6ad5..ba6209e6513 100644 --- a/.external +++ b/.external @@ -1,2 +1,2 @@ -xamarin/monodroid:d16-9@b2a750a2bd9f25e4f16592168dd919bf36930de4 +xamarin/monodroid:d16-9@4163ee94735f4176d2e212041d15c9158316371e mono/mono:2020-02@5e9cb6d1c1de430965312927d5aed7fcb27bfa73 diff --git a/Documentation/guides/building-apps/build-properties.md b/Documentation/guides/building-apps/build-properties.md index c17034da0ab..334630b52e3 100644 --- a/Documentation/guides/building-apps/build-properties.md +++ b/Documentation/guides/building-apps/build-properties.md @@ -986,6 +986,20 @@ To use a file located at `C:\Users\user1\AndroidSigningPassword.txt`: > The `env:` prefix is not supported when [`$(AndroidPackageFormat)`](#androidpackageformat) > is set to `aab`. +## AndroidSigningPlatformKey + +Specifies the key file to use to sign the apk. +This is only used when building `system` applications. + +Support for this property was added in Xamarin.Android 11.3. + +## AndroidSigningPlatformCert + +Specifies the certificate file to use to sign the apk. +This is only used when building `system` applications. + +Support for this property was added in Xamarin.Android 11.3. + ## AndroidSupportedAbis A string property that contains a diff --git a/Documentation/guides/messages/xa4310.md b/Documentation/guides/messages/xa4310.md index 4ff5e383ae5..f6a0241ea03 100644 --- a/Documentation/guides/messages/xa4310.md +++ b/Documentation/guides/messages/xa4310.md @@ -8,17 +8,14 @@ ms.date: 03/09/2020 ## Example messages ``` -error XA4310: `$(AndroidSigningKeyStore)` file `filename.keystore` could not be found. +error XA4310: `$(Property)` file `filename.keystore` could not be found. ``` ## Issue -The specified `$(AndroidSigningKeyStore)` file could not be located on disk. +The specified `$(Property)` file could not be located on disk. ## Solution -Check that the `$(AndroidSigningKeyStore)` MSBuild property is set to a valid -path of an existing keystore. - -This property corresponds to the **Keystore** field in the **Android Package -Signing** section of the Visual Studio project property pages. +Check that the `$(Property)` MSBuild property is set to a valid +path of an existing file. diff --git a/Documentation/release-notes/5708.md b/Documentation/release-notes/5708.md new file mode 100644 index 00000000000..47642fc1277 --- /dev/null +++ b/Documentation/release-notes/5708.md @@ -0,0 +1,13 @@ +#### Application build and deployment + +* [Developer Community 1288717][0]: + *Support Fast Deployment for System Applications.* + Added support for fast deployment while building system based + applications. Applications developed in this mode need to be + signed with a platform key and have a special attribute + + `android:sharedUserId="android.uid.system"` + + in the `AndroidManifest.xml`. + +[0]: https://developercommunity.visualstudio.com/t/VS-2019-1690-Error-XA0130-XamarinAndr/1359238 \ No newline at end of file diff --git a/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/StartAndroidEmulator.cs b/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/StartAndroidEmulator.cs index 4a9038a2eab..25bae993844 100644 --- a/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/StartAndroidEmulator.cs +++ b/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/StartAndroidEmulator.cs @@ -20,6 +20,7 @@ public class StartAndroidEmulator : Task public string AndroidSdkHome {get; set;} public string Port {get; set;} public string ImageName {get; set;} = "XamarinAndroidTestRunner64"; + public string Arguments {get; set;} public string ToolPath {get; set;} public string ToolExe {get; set;} @@ -62,7 +63,7 @@ void Run (string emulator) return; var port = string.IsNullOrEmpty (Port) ? "" : $" -port {Port}"; - var arguments = $"-verbose -avd {ImageName}{port} -cache-size 512"; + var arguments = $"{Arguments ?? string.Empty} -verbose -avd {ImageName}{port} -cache-size 512"; Log.LogMessage (MessageImportance.Low, $"Tool {emulator} execution started with arguments: {arguments}"); var psi = new ProcessStartInfo () { FileName = emulator, diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index 349b9ca0a1a..66f5250f58c 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -63,7 +63,7 @@ variables: # - This is a non-fork branch with name containing "mono-" (for Mono bumps) IsMonoBranch: $[and(eq(variables['XA.Commercial.Build'], 'true'), ne(variables['System.PullRequest.IsFork'], 'True'), or(contains(variables['Build.SourceBranchName'], 'mono-'), contains(variables['System.PullRequest.SourceBranch'], 'mono-')))] RunAllTests: $[or(eq(variables['XA.RunAllTests'], true), eq(variables['IsMonoBranch'], true))] - DotNetNUnitCategories: '& TestCategory != DotNetIgnore & TestCategory != AOT & TestCategory != MkBundle & TestCategory != MonoSymbolicate & TestCategory != PackagesConfig & TestCategory != StaticProject & TestCategory != Debugger' + DotNetNUnitCategories: '& TestCategory != DotNetIgnore & TestCategory != AOT & TestCategory != MkBundle & TestCategory != MonoSymbolicate & TestCategory != PackagesConfig & TestCategory != StaticProject & TestCategory != Debugger & TestCategory != SystemApplication' NUnit.NumberOfTestWorkers: 4 GitHub.Token: $(github--pat--vs-mobiletools-engineering-service2) diff --git a/build-tools/automation/yaml-templates/run-msbuild-device-tests.yaml b/build-tools/automation/yaml-templates/run-msbuild-device-tests.yaml index d764a8c837c..eea436b3bdc 100644 --- a/build-tools/automation/yaml-templates/run-msbuild-device-tests.yaml +++ b/build-tools/automation/yaml-templates/run-msbuild-device-tests.yaml @@ -57,7 +57,7 @@ jobs: useDotNet: $(UseDotNet) testRunTitle: MSBuildDeviceIntegration On Device - macOS - ${{ parameters.job_suffix }} testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/${{ parameters.target_framework }}/MSBuildDeviceIntegration.dll - nunitConsoleExtraArgs: --where "cat != TimeZoneInfo && cat != SmokeTests ${{ parameters.nunit_categories }}" + nunitConsoleExtraArgs: --where "cat != SystemApplication && cat != TimeZoneInfo && cat != SmokeTests ${{ parameters.nunit_categories }}" dotNetTestExtraArgs: --filter "TestCategory != TimeZoneInfo & TestCategory != SmokeTests ${{ parameters.nunit_categories }}" testResultsFile: TestResult-MSBuildDeviceIntegration-${{ parameters.job_name }}-$(XA.Build.Configuration).xml diff --git a/build-tools/automation/yaml-templates/run-systemapp-tests.yaml b/build-tools/automation/yaml-templates/run-systemapp-tests.yaml new file mode 100644 index 00000000000..89d43bcae7c --- /dev/null +++ b/build-tools/automation/yaml-templates/run-systemapp-tests.yaml @@ -0,0 +1,52 @@ +# Runs TimeZoneInfo tests against an emulator running on macOS + +jobs: + - job: mac_systemapp_tests + displayName: System App Emulator Tests + pool: + vmImage: $(HostedMacImage) + timeoutInMinutes: 120 + cancelTimeoutInMinutes: 5 + workspace: + clean: all + steps: + - template: setup-test-environment.yaml + + - script: mono $(System.DefaultWorkingDirectory)/build-tools/xaprepare/xaprepare/bin/$(XA.Build.Configuration)/xaprepare.exe --s=EmulatorTestDependencies --no-emoji --run-mode=CI + displayName: install emulator + + - task: DownloadPipelineArtifact@2 + inputs: + artifactName: $(TestAssembliesArtifactName) + downloadPath: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration) + + - task: MSBuild@1 + displayName: start emulator + inputs: + solution: tests/Mono.Android-Tests/Mono.Android-Tests.csproj + configuration: $(XA.Build.Configuration) + msbuildArguments: >- + /t:AcquireAndroidTarget /p:TestEmulatorArguments=-writable-system /bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/start-emulator.binlog + + - template: run-nunit-tests.yaml + parameters: + testRunTitle: System App On Device - macOS + testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/MSBuildDeviceIntegration/net472/MSBuildDeviceIntegration.dll + nunitConsoleExtraArgs: --where "cat == SystemApplication" + testResultsFile: TestResult-SystemApp--$(XA.Build.Configuration).xml + + - task: MSBuild@1 + displayName: shut down emulator + inputs: + solution: tests/Mono.Android-Tests/Mono.Android-Tests.csproj + configuration: $(XA.Build.Configuration) + msbuildArguments: >- + /t:AcquireAndroidTarget,ReleaseAndroidTarget + /bl:$(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/shutdown-emulator.binlog + condition: always() + + - template: upload-results.yaml + parameters: + artifactName: Test Results - System App With Emulator - macOS + + - template: fail-on-issue.yaml \ No newline at end of file diff --git a/build-tools/scripts/TestApks.targets b/build-tools/scripts/TestApks.targets index fa1839490c4..66416b540dd 100644 --- a/build-tools/scripts/TestApks.targets +++ b/build-tools/scripts/TestApks.targets @@ -57,6 +57,7 @@ The following are literal names and should not be translated: MultiDexMainDexList - `$(AndroidSigningKeyStore)` file `{0}` could not be found. - The following are literal names and should not be translated: `$(AndroidSigningKeyStore)` + `{0}` file `{1}` could not be found. + {0} - The MSBuildProperty which contains the file name value. +{1} - The value of the MSBuildProperty. Normally a filename. + The application won't contain the paired Wear package because the Wear application package APK is not created yet. If building on the command line, be sure to build the "SignAndroidPackage" target. diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.cs.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.cs.xlf index 89758e91cd3..6512e839176 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.cs.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.cs.xlf @@ -744,9 +744,11 @@ In this message, "root element" refers to the root element of an XML file. The following are literal names and should not be translated: MultiDexMainDexList - `$(AndroidSigningKeyStore)` file `{0}` could not be found. - Soubor $(AndroidSigningKeyStore) {0} se nepovedlo najít. - The following are literal names and should not be translated: `$(AndroidSigningKeyStore)` + `{0}` file `{1}` could not be found. + Soubor {0} {1} se nepovedlo najít. + {0} - The MSBuildProperty which contains the file name value. +{1} - The value of the MSBuildProperty. Normally a filename. + The application won't contain the paired Wear package because the Wear application package APK is not created yet. If building on the command line, be sure to build the "SignAndroidPackage" target. diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.de.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.de.xlf index e8842a503a9..78e6228bb7c 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.de.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.de.xlf @@ -744,9 +744,11 @@ In this message, "root element" refers to the root element of an XML file. The following are literal names and should not be translated: MultiDexMainDexList - `$(AndroidSigningKeyStore)` file `{0}` could not be found. - Die $(AndroidSigningKeyStore)-Datei "{0}" wurde nicht gefunden. - The following are literal names and should not be translated: `$(AndroidSigningKeyStore)` + `{0}` file `{1}` could not be found. + Die {0}-Datei "{1}" wurde nicht gefunden. + {0} - The MSBuildProperty which contains the file name value. +{1} - The value of the MSBuildProperty. Normally a filename. + The application won't contain the paired Wear package because the Wear application package APK is not created yet. If building on the command line, be sure to build the "SignAndroidPackage" target. diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.es.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.es.xlf index 7891fde05f0..0e9017dc780 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.es.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.es.xlf @@ -744,9 +744,11 @@ In this message, "root element" refers to the root element of an XML file. The following are literal names and should not be translated: MultiDexMainDexList - `$(AndroidSigningKeyStore)` file `{0}` could not be found. - No se ha encontrado el archivo "{0}" de "$(AndroidSigningKeyStore)". - The following are literal names and should not be translated: `$(AndroidSigningKeyStore)` + `{0}` file `{1}` could not be found. + No se ha encontrado el archivo "{1}" de "{0}". + {0} - The MSBuildProperty which contains the file name value. +{1} - The value of the MSBuildProperty. Normally a filename. + The application won't contain the paired Wear package because the Wear application package APK is not created yet. If building on the command line, be sure to build the "SignAndroidPackage" target. diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.fr.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.fr.xlf index 0db56b97c2e..11e112254a6 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.fr.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.fr.xlf @@ -744,9 +744,11 @@ In this message, "root element" refers to the root element of an XML file. The following are literal names and should not be translated: MultiDexMainDexList - `$(AndroidSigningKeyStore)` file `{0}` could not be found. - Le fichier '$(AndroidSigningKeyStore)' '{0}' est introuvable. - The following are literal names and should not be translated: `$(AndroidSigningKeyStore)` + `{0}` file `{1}` could not be found. + Le fichier '{0}' '{1}' est introuvable. + {0} - The MSBuildProperty which contains the file name value. +{1} - The value of the MSBuildProperty. Normally a filename. + The application won't contain the paired Wear package because the Wear application package APK is not created yet. If building on the command line, be sure to build the "SignAndroidPackage" target. diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.it.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.it.xlf index bb577873790..b39ce8c3630 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.it.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.it.xlf @@ -744,9 +744,11 @@ In this message, "root element" refers to the root element of an XML file. The following are literal names and should not be translated: MultiDexMainDexList - `$(AndroidSigningKeyStore)` file `{0}` could not be found. - Non è stato possibile trovare il file `{0}` di `$(AndroidSigningKeyStore)`. - The following are literal names and should not be translated: `$(AndroidSigningKeyStore)` + `{0}` file `{1}` could not be found. + Non è stato possibile trovare il file `{1}` di `{0}`. + {0} - The MSBuildProperty which contains the file name value. +{1} - The value of the MSBuildProperty. Normally a filename. + The application won't contain the paired Wear package because the Wear application package APK is not created yet. If building on the command line, be sure to build the "SignAndroidPackage" target. diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ja.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ja.xlf index 1c298b192c0..7b2298e074c 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ja.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ja.xlf @@ -744,9 +744,11 @@ In this message, "root element" refers to the root element of an XML file. The following are literal names and should not be translated: MultiDexMainDexList - `$(AndroidSigningKeyStore)` file `{0}` could not be found. - '$(AndroidSigningKeyStore)' ファイル '{0}' が見つかりませんでした。 - The following are literal names and should not be translated: `$(AndroidSigningKeyStore)` + `{0}` file `{1}` could not be found. + '{0}' ファイル '{1}' が見つかりませんでした。 + {0} - The MSBuildProperty which contains the file name value. +{1} - The value of the MSBuildProperty. Normally a filename. + The application won't contain the paired Wear package because the Wear application package APK is not created yet. If building on the command line, be sure to build the "SignAndroidPackage" target. diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ko.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ko.xlf index 1217ee0f137..e577d85f884 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ko.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ko.xlf @@ -744,9 +744,11 @@ In this message, "root element" refers to the root element of an XML file. The following are literal names and should not be translated: MultiDexMainDexList - `$(AndroidSigningKeyStore)` file `{0}` could not be found. - '$(AndroidSigningKeyStore)' 파일 '{0}'을(를) 찾을 수 없습니다. - The following are literal names and should not be translated: `$(AndroidSigningKeyStore)` + `{0}` file `{1}` could not be found. + '{0}' 파일 '{1}'을(를) 찾을 수 없습니다. + {0} - The MSBuildProperty which contains the file name value. +{1} - The value of the MSBuildProperty. Normally a filename. + The application won't contain the paired Wear package because the Wear application package APK is not created yet. If building on the command line, be sure to build the "SignAndroidPackage" target. diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.pl.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.pl.xlf index f1458e19045..8fde2624c38 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.pl.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.pl.xlf @@ -744,9 +744,11 @@ In this message, "root element" refers to the root element of an XML file. The following are literal names and should not be translated: MultiDexMainDexList - `$(AndroidSigningKeyStore)` file `{0}` could not be found. - Nie można odnaleźć pliku „$(AndroidSigningKeyStore)” („{0}”). - The following are literal names and should not be translated: `$(AndroidSigningKeyStore)` + `{0}` file `{1}` could not be found. + `{0}` file `{1}` could not be found. + {0} - The MSBuildProperty which contains the file name value. +{1} - The value of the MSBuildProperty. Normally a filename. + The application won't contain the paired Wear package because the Wear application package APK is not created yet. If building on the command line, be sure to build the "SignAndroidPackage" target. diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.pt-BR.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.pt-BR.xlf index 78508db3557..556cbdc4a7a 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.pt-BR.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.pt-BR.xlf @@ -744,9 +744,11 @@ In this message, "root element" refers to the root element of an XML file. The following are literal names and should not be translated: MultiDexMainDexList - `$(AndroidSigningKeyStore)` file `{0}` could not be found. - Não foi possível localizar o arquivo `{0}` de `$(AndroidSigningKeyStore)`. - The following are literal names and should not be translated: `$(AndroidSigningKeyStore)` + `{0}` file `{1}` could not be found. + `{0}` file `{1}` could not be found. + {0} - The MSBuildProperty which contains the file name value. +{1} - The value of the MSBuildProperty. Normally a filename. + The application won't contain the paired Wear package because the Wear application package APK is not created yet. If building on the command line, be sure to build the "SignAndroidPackage" target. diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ru.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ru.xlf index 03d949606de..de02a2e6a50 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ru.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ru.xlf @@ -744,9 +744,11 @@ In this message, "root element" refers to the root element of an XML file. The following are literal names and should not be translated: MultiDexMainDexList - `$(AndroidSigningKeyStore)` file `{0}` could not be found. - Не удалось найти файл "$(AndroidSigningKeyStore)" с именем "{0}". - The following are literal names and should not be translated: `$(AndroidSigningKeyStore)` + `{0}` file `{1}` could not be found. + `{0}` file `{1}` could not be found. + {0} - The MSBuildProperty which contains the file name value. +{1} - The value of the MSBuildProperty. Normally a filename. + The application won't contain the paired Wear package because the Wear application package APK is not created yet. If building on the command line, be sure to build the "SignAndroidPackage" target. diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.tr.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.tr.xlf index e6c7afb59b1..57016ac3567 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.tr.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.tr.xlf @@ -744,9 +744,11 @@ In this message, "root element" refers to the root element of an XML file. The following are literal names and should not be translated: MultiDexMainDexList - `$(AndroidSigningKeyStore)` file `{0}` could not be found. - `{0}` adlı `$(AndroidSigningKeyStore)` dosyası bulunamadı. - The following are literal names and should not be translated: `$(AndroidSigningKeyStore)` + `{0}` file `{1}` could not be found. + `{0}` file `{1}` could not be found. + {0} - The MSBuildProperty which contains the file name value. +{1} - The value of the MSBuildProperty. Normally a filename. + The application won't contain the paired Wear package because the Wear application package APK is not created yet. If building on the command line, be sure to build the "SignAndroidPackage" target. diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.zh-Hans.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.zh-Hans.xlf index f95f935c730..6ed753343bb 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.zh-Hans.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.zh-Hans.xlf @@ -744,9 +744,11 @@ In this message, "root element" refers to the root element of an XML file. The following are literal names and should not be translated: MultiDexMainDexList - `$(AndroidSigningKeyStore)` file `{0}` could not be found. - 找不到“$(AndroidSigningKeyStore)”文件“{0}”。 - The following are literal names and should not be translated: `$(AndroidSigningKeyStore)` + `{0}` file `{1}` could not be found. + `{0}` file `{1}` could not be found. + {0} - The MSBuildProperty which contains the file name value. +{1} - The value of the MSBuildProperty. Normally a filename. + The application won't contain the paired Wear package because the Wear application package APK is not created yet. If building on the command line, be sure to build the "SignAndroidPackage" target. diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.zh-Hant.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.zh-Hant.xlf index a41cf9bd506..74d7effeda8 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.zh-Hant.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.zh-Hant.xlf @@ -744,9 +744,11 @@ In this message, "root element" refers to the root element of an XML file. The following are literal names and should not be translated: MultiDexMainDexList - `$(AndroidSigningKeyStore)` file `{0}` could not be found. - 找不到 `$(AndroidSigningKeyStore)` 檔案 `{0}`。 - The following are literal names and should not be translated: `$(AndroidSigningKeyStore)` + `{0}` file `{1}` could not be found. + `{0}` file `{1}` could not be found. + {0} - The MSBuildProperty which contains the file name value. +{1} - The value of the MSBuildProperty. Normally a filename. + The application won't contain the paired Wear package because the Wear application package APK is not created yet. If building on the command line, be sure to build the "SignAndroidPackage" target. diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/AndroidApkSigner.cs b/src/Xamarin.Android.Build.Tasks/Tasks/AndroidApkSigner.cs index 8eda5111c93..84ac135b33f 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/AndroidApkSigner.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/AndroidApkSigner.cs @@ -19,34 +19,34 @@ public class AndroidApkSigner : JavaToolTask [Required] public ITaskItem ManifestFile { get; set; } - [Required] public string KeyStore { get; set; } - [Required] public string KeyAlias { get; set; } + public string PlatformKey { get; set; } + + public string PlatformCert { get; set; } + /// /// The Password for the Key. /// You can use the raw password here, however if you want to hide your password in logs - /// you can use a preview of env: or file: to point it to an Environment variable or + /// you can use a preview of env: or file: to point it to an Environment variable or /// a file. /// /// env: - /// file: + /// file: /// - [Required] public string KeyPass { get; set; } /// /// The Password for the Keystore. /// You can use the raw password here, however if you want to hide your password in logs - /// you can use a preview of env: or file: to point it to an Environment variable or + /// you can use a preview of env: or file: to point it to an Environment variable or /// a file. /// /// env: - /// file: + /// file: /// - [Required] public string StorePass { get; set; } public string AdditionalArguments { get; set; } @@ -80,13 +80,21 @@ protected override string GenerateCommandLineCommands () cmd.AppendSwitchIfNotNull ("-jar ", ApkSignerJar); cmd.AppendSwitch ("sign"); - cmd.AppendSwitchIfNotNull ("--ks ", KeyStore); - AddStorePass (cmd, "--ks-pass", StorePass); - cmd.AppendSwitchIfNotNull ("--ks-key-alias ", KeyAlias); - AddStorePass (cmd, "--key-pass", KeyPass); + + if (!string.IsNullOrEmpty (PlatformKey) && !string.IsNullOrEmpty (PlatformCert)) { + cmd.AppendSwitchIfNotNull ("--key ", PlatformKey); + cmd.AppendSwitchIfNotNull ("--cert ", PlatformCert); + } else { + cmd.AppendSwitchIfNotNull ("--ks ", KeyStore); + AddStorePass (cmd, "--ks-pass", StorePass); + cmd.AppendSwitchIfNotNull ("--ks-key-alias ", KeyAlias); + AddStorePass (cmd, "--key-pass", KeyPass); + } + cmd.AppendSwitchIfNotNull ("--min-sdk-version ", minSdk.ToString ()); cmd.AppendSwitchIfNotNull ("--max-sdk-version ", maxSdk.ToString ()); - + + if (!string.IsNullOrEmpty (AdditionalArguments)) cmd.AppendSwitch (AdditionalArguments); @@ -115,9 +123,20 @@ protected override string ToolName { protected override bool ValidateParameters () { - if (!string.IsNullOrEmpty (KeyStore) && !File.Exists (KeyStore)) { - Log.LogCodedError ("XA4310", Properties.Resources.XA4310, KeyStore); - return false; + if (!string.IsNullOrEmpty (PlatformKey) && !string.IsNullOrEmpty (PlatformCert)) { + if (!File.Exists (PlatformKey)) { + Log.LogCodedError ("XA4310", Properties.Resources.XA4310, "$(AndroidSigningPlatformKey)", PlatformKey); + return false; + } + if (!File.Exists (PlatformCert)) { + Log.LogCodedError ("XA4310", Properties.Resources.XA4310, "$(AndroidSigningPlatformCert)", PlatformCert); + return false; + } + } else { + if (!string.IsNullOrEmpty (KeyStore) && !File.Exists (KeyStore)) { + Log.LogCodedError ("XA4310", Properties.Resources.XA4310, "$(AndroidSigningKeyStore)", KeyStore); + return false; + } } return base.ValidateParameters (); } diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/AndroidSignPackage.cs b/src/Xamarin.Android.Build.Tasks/Tasks/AndroidSignPackage.cs index 6d1e4096896..e0bb5ffe7b4 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/AndroidSignPackage.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/AndroidSignPackage.cs @@ -20,30 +20,30 @@ public class AndroidSignPackage : AndroidRunToolTask [Required] [Output] public string KeyStore { get; set; } - + [Required] public string KeyAlias { get; set; } - + /// /// The Password for the Key. /// You can use the raw password here, however if you want to hide your password in logs - /// you can use a preview of env: or file: to point it to an Environment variable or + /// you can use a preview of env: or file: to point it to an Environment variable or /// a file. /// /// env: - /// file: + /// file: /// [Required] public string KeyPass { get; set; } - + /// /// The Password for the Keystore. /// You can use the raw password here, however if you want to hide your password in logs - /// you can use a preview of env: or file: to point it to an Environment variable or + /// you can use a preview of env: or file: to point it to an Environment variable or /// a file. /// /// env: - /// file: + /// file: /// [Required] public string StorePass { get; set; } @@ -150,7 +150,7 @@ protected override string ToolName protected override bool ValidateParameters () { if (!string.IsNullOrEmpty (KeyStore) && !File.Exists (KeyStore)) { - Log.LogCodedError ("XA4310", Properties.Resources.XA4310, KeyStore); + Log.LogCodedError ("XA4310", Properties.Resources.XA4310, "$(AndroidSigningKeyStore)", KeyStore); return false; } return base.ValidateParameters (); diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs index 94de779bfc0..68fba8bb9f2 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/DeviceTest.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using System.Xml.Linq; using System.Xml.XPath; +using Xamarin.ProjectTools; namespace Xamarin.Android.Build.Tests { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/ResourceData.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/ResourceData.cs index bc43429577d..9db163daf8d 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/ResourceData.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/ResourceData.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using Xamarin.ProjectTools; namespace Xamarin.Android.Build.Tests { @@ -25,5 +26,15 @@ static byte[] GetResourceData (string name) return m.ToArray (); } } + + public static byte [] GetKeystore (string keyname = "test.keystore") + { + var assembly = typeof (XamarinAndroidCommonProject).Assembly; + using (var stream = assembly.GetManifestResourceStream ($"Xamarin.ProjectTools.Resources.Base.{keyname}")) { + var data = new byte [stream.Length]; + stream.Read (data, 0, (int) stream.Length); + return data; + } + } } } diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets index e1c331b15dc..5b4a80e749a 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets @@ -2278,6 +2278,8 @@ because xbuild doesn't support framework reference assemblies. KeyAlias="$(_ApkKeyAlias)" KeyPass="$(_ApkKeyPass)" StorePass="$(_ApkStorePass)" + PlatformKey="$(AndroidSigningPlatformKey)" + PlatformCert="$(AndroidSigningPlatformCert)" ToolPath="$(JavaToolPath)" ToolExe="$(JavaToolExe)" ManifestFile="$(IntermediateOutputPath)android\AndroidManifest.xml" diff --git a/tests/MSBuildDeviceIntegration/Tests/InstallTests.cs b/tests/MSBuildDeviceIntegration/Tests/InstallTests.cs index d33300a2081..99c28fd08db 100644 --- a/tests/MSBuildDeviceIntegration/Tests/InstallTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/InstallTests.cs @@ -15,16 +15,6 @@ namespace Xamarin.Android.Build.Tests [Category ("Commercial"), Category ("UsesDevice")] public class InstallTests : DeviceTest { - static byte [] GetKeystore () - { - var assembly = typeof (XamarinAndroidCommonProject).Assembly; - using (var stream = assembly.GetManifestResourceStream ("Xamarin.ProjectTools.Resources.Base.test.keystore")) { - var data = new byte [stream.Length]; - stream.Read (data, 0, (int) stream.Length); - return data; - } - } - string GetContentFromAllOverrideDirectories (string packageName, bool useRunAsCommand = true) { var adbShellArgs = $"shell run-as {packageName} ls"; @@ -114,7 +104,7 @@ public void ChangeKeystoreRedeploy () using (var builder = CreateApkBuilder ()) { // Use the default debug.keystore XA generates Assert.IsTrue (builder.Install (proj), "first install should succeed."); - byte [] data = GetKeystore (); + byte [] data = ResourceData.GetKeystore (); proj.OtherBuildItems.Add (new BuildItem (BuildActions.None, "test.keystore") { BinaryContent = () => data }); @@ -380,7 +370,7 @@ public void TestAndroidStoreKey (bool useApkSigner, bool isRelease, string packa string path = Path.Combine ("temp", TestName.Replace (expected, expected.Replace ("-", "_"))); string storepassfile = Path.Combine (Root, path, "storepass.txt"); string keypassfile = Path.Combine (Root, path, "keypass.txt"); - byte [] data = GetKeystore (); + byte [] data = ResourceData.GetKeystore (); var proj = new XamarinAndroidApplicationProject () { IsRelease = isRelease }; @@ -565,6 +555,5 @@ public void IncrementalFastDeployment () $"Fourth unchanged install: '{fourthInstalTime}' should be faster than clean install: '{firstInstallTime}' and incremental install: '{thirdInstallTime}'."); } } - } } diff --git a/tests/MSBuildDeviceIntegration/Tests/SystemApplicationTests.cs b/tests/MSBuildDeviceIntegration/Tests/SystemApplicationTests.cs new file mode 100644 index 00000000000..117e84d51a5 --- /dev/null +++ b/tests/MSBuildDeviceIntegration/Tests/SystemApplicationTests.cs @@ -0,0 +1,47 @@ +using System; +using NUnit.Framework; +using Xamarin.ProjectTools; +using System.IO; +using System.Linq; +using Microsoft.Build.Framework; +using System.Text; +using System.Xml.Linq; +using System.Collections.Generic; + +namespace Xamarin.Android.Build.Tests +{ + [TestFixture] + [NonParallelizable] //These tests deploy to devices + [Category ("Commercial"), Category ("UsesDevice")] + public class SystemApplicationTests : DeviceTest + { + // All Tests here require the emulator to be started with -writable-system + [Test, Category ("SystemApplication")] + public void SystemApplicationCanInstall () + { + AssertCommercialBuild (); + AssertHasDevices (); + + var proj = new XamarinAndroidApplicationProject () { + IsRelease = false, + EmbedAssembliesIntoApk = false, + }; + proj.OtherBuildItems.Add (new BuildItem ("None", "platform.pk8") { + WebContent = "https://github.com/aosp-mirror/platform_build/raw/master/target/product/security/platform.pk8" + }); + proj.OtherBuildItems.Add (new BuildItem ("None", "platform.x509.pem") { + WebContent = "https://github.com/aosp-mirror/platform_build/raw/master/target/product/security/platform.x509.pem" + }); + proj.AndroidManifest = proj.AndroidManifest.Replace ("