From 3653ec3dfaf090d6f3aec7cd193056a9d10197d7 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 20 Jul 2023 16:57:14 -0500 Subject: [PATCH 01/44] $(AndroidPackVersionSuffix)=rc.1; net8 is 34.0.0-rc.1 (#8204) Context: https://github.com/xamarin/xamarin-android/tree/release/8.0.1xx-preview7 We branched for .NET 8 preview 7 from 7bf4eddb into `release/8.0.1xx-preview7`. Update xamarin-android/main's version number to 34.0.0-rc.1 for .NET 8 RC 1. --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index d439023a48a..86f4311a120 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -35,7 +35,7 @@ * Bump first digit of the patch version for feature releases (and reset the first two digits to 0) --> 34.0.0 - preview.7 + rc.1 From 215ab4d382de9993d6861acbb8dd6fefc9e4c603 Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Mon, 24 Jul 2023 15:50:22 -0400 Subject: [PATCH 02/44] [vs-workload] Set EnableSideBySideManifests=true (#8179) Context: https://github.com/xamarin/yaml-templates/pull/274 Enables side by side workload manifest support when generating workload MSIs. This should only be enabled for builds shipping with .NET 8 Preview 7 or later. --- build-tools/create-packs/vs-workload.in.props | 1 + 1 file changed, 1 insertion(+) diff --git a/build-tools/create-packs/vs-workload.in.props b/build-tools/create-packs/vs-workload.in.props index ddb735bf0c7..0402cf82645 100644 --- a/build-tools/create-packs/vs-workload.in.props +++ b/build-tools/create-packs/vs-workload.in.props @@ -3,6 +3,7 @@ Microsoft.NET.Sdk.Android.Workload.@VSMAN_VERSION@ @WORKLOAD_VERSION@ + true From 805872bc4c92bc63120e54518952ccc5326991e8 Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Mon, 24 Jul 2023 19:56:36 -0400 Subject: [PATCH 03/44] [ci] Add MAUI integration job (#8200) Adds a new MAUI test stage and job that will run against PR builds targeting xamarin-android/main. The new job will build dotnet/maui against the Android packs produced by the PR build. If that is successful, it will install the MAUI packs into Androids dotnet preview sandbox, and create and build a template. --- build-tools/automation/azure-pipelines.yaml | 135 +++++++++++++++++++- build-tools/scripts/DotNet.targets | 35 ++++- 2 files changed, 165 insertions(+), 5 deletions(-) diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index 8f0cd6df4ac..733e73cdc52 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -30,6 +30,11 @@ resources: name: xamarin/release-scripts ref: refs/heads/sign-and-notarized endpoint: xamarin + - repository: maui + type: github + name: dotnet/maui + ref: refs/heads/net8.0 + endpoint: xamarin parameters: - name: provisionatorChannel @@ -277,13 +282,139 @@ stages: artifactName: Test Results - MSBuild Smoke - Linux - template: yaml-templates/fail-on-issue.yaml - + - template: yaml-templates/stage-msbuild-tests.yaml - + - template: yaml-templates/stage-msbuild-emulator-tests.yaml parameters: usesCleanImages: ${{ parameters.macTestAgentsUseCleanImages }} +- stage: maui_tests + displayName: MAUI Tests + dependsOn: mac_build + condition: eq(variables['System.PullRequest.TargetBranch'], 'main') + jobs: + # Check - "Xamarin.Android (MAUI Tests MAUI Integration)" + - job: maui_tests_integration + displayName: MAUI Integration + pool: $(1ESWindowsPool) + timeoutInMinutes: 180 + workspace: + clean: all + variables: + BuildVersion: $(Build.BuildId) + steps: + - checkout: maui + clean: true + submodules: recursive + path: s/maui + persistCredentials: true + + - template: yaml-templates/setup-test-environment.yaml + parameters: + xaSourcePath: $(Build.SourcesDirectory)/xamarin-android + provisionClassic: false + provisionatorChannel: ${{ parameters.provisionatorChannel }} + installLegacyDotNet: false + restoreNUnitConsole: false + updateMono: false + androidSdkPlatforms: 23,24,25,26,27,28,29,30,31,32,$(DefaultTestSdkPlatforms) + + - task: NuGetAuthenticate@0 + displayName: authenticate with azure artifacts + inputs: + forceReinstallCredentialProvider: true + + - script: | + echo ##vso[task.setvariable variable=JI_JAVA_HOME]%JAVA_HOME_11_X64% + echo ##vso[task.setvariable variable=JAVA_HOME]%JAVA_HOME_11_X64% + displayName: set JI_JAVA_HOME, JAVA_HOME + + - task: DownloadPipelineArtifact@2 + inputs: + artifactName: $(NuGetArtifactName) + downloadPath: $(Build.StagingDirectory)/android-packs + + - pwsh: | + $searchPath = Join-Path $(Build.StagingDirectory) android-packs + $wlmanPack = Get-ChildItem $searchPath -Filter *Android*Manifest*.nupkg | Select-Object -First 1 + $dest = Join-Path $searchPath "tmp-wlman" "$($wlmanPack.BaseName)" + Expand-Archive -LiteralPath $wlmanPack -DestinationPath $dest + $wlmanJsonPath = Join-Path $dest "data" "WorkloadManifest.json" + $json = Get-Content $wlmanJsonPath | ConvertFrom-Json -AsHashtable + Write-Host "Setting variable ANDROID_PACK_VERSION = $($json["version"])" + Write-Host "##vso[task.setvariable variable=ANDROID_PACK_VERSION;]$($json["version"])" + displayName: Set ANDROID_PACK_VERSION + + - pwsh: >- + $(Build.SourcesDirectory)/maui/eng/scripts/update-version-props.ps1 + -xmlFileName "$(Build.SourcesDirectory)/maui/eng/Versions.props" + -androidVersion $(ANDROID_PACK_VERSION) + displayName: Update MAUI's Android dependency + + - pwsh: ./build.ps1 --target=dotnet --configuration="$(XA.Build.Configuration)" --nugetsource="$(Build.StagingDirectory)\android-packs" --verbosity=diagnostic + displayName: Install .NET + retryCountOnTaskFailure: 3 + workingDirectory: $(Build.SourcesDirectory)/maui + + - pwsh: ./build.ps1 --target=dotnet-pack --configuration="$(XA.Build.Configuration)" --nugetsource="$(Build.StagingDirectory)\android-packs" --verbosity=diagnostic + displayName: Pack .NET Maui + workingDirectory: $(Build.SourcesDirectory)/maui + + - task: DotNetCoreCLI@2 + displayName: Install MAUI workload packs + retryCountOnTaskFailure: 3 + inputs: + projects: $(Build.SourcesDirectory)/xamarin-android/Xamarin.Android.sln + arguments: -t:InstallMaui -p:MauiUseLocalPacks=true -p:MauiWorkloadToInstall=maui -c $(XA.Build.Configuration) --no-restore -v:n -bl:$(Build.StagingDirectory)/logs/install-maui.binlog + + - template: yaml-templates/run-dotnet-preview.yaml + parameters: + command: new + arguments: maui -o $(Build.StagingDirectory)/MauiTestProj + xaSourcePath: $(Build.SourcesDirectory)/xamarin-android + displayName: Create MAUI template + continueOnError: false + + - template: yaml-templates/run-dotnet-preview.yaml + parameters: + project: $(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj + arguments: >- + -f $(DotNetTargetFramework)-android -c Debug + --configfile $(Build.SourcesDirectory)/maui/NuGet.config + -bl:$(Build.StagingDirectory)/logs/MauiTestProj-Debug.binlog + xaSourcePath: $(Build.SourcesDirectory)/xamarin-android + displayName: Build MAUI template - Debug + + - template: yaml-templates/run-dotnet-preview.yaml + parameters: + project: $(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj + arguments: >- + -f $(DotNetTargetFramework)-android -c Release + --configfile $(Build.SourcesDirectory)/maui/NuGet.config + -bl:$(Build.StagingDirectory)/logs/MauiTestProj-Release.binlog + xaSourcePath: $(Build.SourcesDirectory)/xamarin-android + displayName: Build MAUI template - Release + + - task: CopyFiles@2 + displayName: copy build logs + condition: always() + inputs: + Contents: | + $(Build.SourcesDirectory)/maui/artifacts/logs/** + TargetFolder: $(Build.StagingDirectory)/logs + flattenFolders: true + + - template: yaml-templates/publish-artifact.yaml + parameters: + displayName: upload build and test results + artifactName: Test Results - MAUI Integration + targetPath: $(Build.StagingDirectory)/logs + condition: or(ne(variables['Agent.JobStatus'], 'Succeeded'), eq(variables['XA.PublishAllLogs'], 'true')) + + - template: yaml-templates/fail-on-issue.yaml + + - stage: dotnet_prepare_release displayName: Prepare .NET Release dependsOn: diff --git a/build-tools/scripts/DotNet.targets b/build-tools/scripts/DotNet.targets index e11b2042001..ba9d8d5f7f1 100644 --- a/build-tools/scripts/DotNet.targets +++ b/build-tools/scripts/DotNet.targets @@ -3,24 +3,28 @@ <_Root>$(MSBuildThisFileDirectory)..\..\ <_BinlogPathPrefix>$(_Root)bin/Build$(Configuration)/msbuild-$([System.DateTime]::Now.ToString("yyyyMMddTHHmmss")) + + + + + - + <_TempDirectory>$(DotNetPreviewPath)..\.xa-workload-temp-$([System.IO.Path]::GetRandomFileName()) $(DotNetSdkManifestsFolder) + false + $(XamarinAndroidSourcePath)..\maui + $(MauiSourcePath)\artifacts + maui-android + + + + <_WLManifestPack Include="$(MauiPackagePath)\Microsoft.NET.Sdk.Maui.Manifest-$(MauiVersionBand.Substring (0,3))*.nupkg" /> + + - <_WLManifest Include="$(_TempDirectory)\microsoft.net.sdk.maui.manifest-$(MauiVersionBand)\$(MauiVersion)\data\WorkloadManifest.*" /> + <_WLManifest Condition=" '$(MauiUseLocalPacks)' != 'true' " Include="$(_TempDirectory)\microsoft.net.sdk.maui.manifest-$(MauiVersionBand)\$(MauiVersion)\data\WorkloadManifest.*" /> + <_WLManifest Condition=" '$(MauiUseLocalPacks)' == 'true' " Include="$(_TempDirectory)\data\*" /> + + + + <_NuGetSources Condition=" '$(MauiUseLocalPacks)' == 'true' " Include="$(MauiPackagePath.TrimEnd('\'))" /> <_NuGetSources Include="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json" /> <_NuGetSources Include="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" /> <_InstallArguments Include="--skip-manifest-update" /> @@ -78,7 +107,7 @@ <_InstallArguments Include="--temp-dir "$(_TempDirectory)"" /> From d9e440710574e3d261faa4514eb1a46091bca9b9 Mon Sep 17 00:00:00 2001 From: Jonathan Pobst Date: Tue, 25 Jul 2023 15:26:07 -0500 Subject: [PATCH 04/44] [Mono.Android] Fix Context.RegisterReceiver() enumification (#7735) Fixes: https://github.com/xamarin/xamarin-android/issues/7503 Context: e33eb53407bc85f0b9a0f6c41d9ec009371eedcc Context: df6c716e4168d14fe4d02cf955de5b6b081b9416 Context: 76ab8b2ca208a73834c70453193e5ec7ef1f7304 The bindings for [`Context.registerReceiver(BroadcastReceiver, IntentFilter, int)`][0] and related overloads incorrectly enumified the `int` parameter as the `Android.Content.ActivityFlags` enum (e33eb534), when it should have been `Android.Content.ReceiverFlags` (df6c716e). Unfortunately we can't directly fix this, as the bound `Context.RegisterReceiver(BroadcastReceiver, IntentFilter, ActivityFlags)` method is *`abstract`*, and thus changing it would break compatibility. Fix this without breaking API by: 1. Creating new overload methods which chain to the existing methods 2. Mark the existing methods and method overrides as `[Obsolete]`. a'la: partial class Context { [Obsolete ("This method has an incorrect enumeration type. Use the overload that takes ReceiverFlags instead.")] public abstract Intent? RegisterReceiver (BroadcastReceiver? receiver, IntentFilter? filter, [GeneratedEnum] ActivityFlags flags); public Intent? RegisterReceiver (BroadcastReceiver? receiver, IntentFilter? filter, ReceiverFlags flags) => RegisterReceiver (receiver, filter, (ActivityFlags)flags); } A concern with this approach is that it means that a public `abstract` method is now `[Obsolete]`, which would make it "weird" to override. However, this is a method that should *never* be overridden by user code, so we think this is an acceptable compromise. Additionally, it was noticed that the public API tracking added in 76ab8b2c did not flag this change as an error, only a warning. Convert the RS0016 and RS0017 warnings into errors to ensure that any new public API is accounted for. [0]: https://developer.android.com/reference/android/content/Context#registerReceiver(android.content.BroadcastReceiver,%20android.content.IntentFilter,%20int) --- src/Mono.Android/Android.Content/Context.cs | 10 ++++++++++ src/Mono.Android/Mono.Android.csproj | 5 +++++ .../PublicAPI/API-34/PublicAPI.Unshipped.txt | 2 ++ src/Mono.Android/metadata | 8 ++++++++ 4 files changed, 25 insertions(+) diff --git a/src/Mono.Android/Android.Content/Context.cs b/src/Mono.Android/Android.Content/Context.cs index d397c171207..62896ab8dd9 100644 --- a/src/Mono.Android/Android.Content/Context.cs +++ b/src/Mono.Android/Android.Content/Context.cs @@ -1,4 +1,5 @@ using System; +using Android.OS; using Android.Runtime; namespace Android.Content { @@ -16,5 +17,14 @@ public void StartActivity (Type type) [Obsolete ("This constant will be removed in the future version. Use Android.Content.ReceiverFlags enum directly instead of this field.")] public const int ReceiverVisibleToInstantApps = 1; #endif + +#if ANDROID_34 + // Add correctly enumified overloads + public Intent? RegisterReceiver (BroadcastReceiver? receiver, IntentFilter? filter, ReceiverFlags flags) + => RegisterReceiver (receiver, filter, (ActivityFlags)flags); + + public Intent? RegisterReceiver (BroadcastReceiver? receiver, IntentFilter? filter, string? broadcastPermission, Handler? scheduler, ReceiverFlags flags) + => RegisterReceiver (receiver, filter, broadcastPermission, scheduler, (ActivityFlags)flags); +#endif } } diff --git a/src/Mono.Android/Mono.Android.csproj b/src/Mono.Android/Mono.Android.csproj index b4444de2a54..71da67f2a0c 100644 --- a/src/Mono.Android/Mono.Android.csproj +++ b/src/Mono.Android/Mono.Android.csproj @@ -27,7 +27,12 @@ $(DefineConstants);ANDROID_UNSTABLE $(_MonoAndroidNETDefaultOutDir) + + false + + + $(WarningsAsErrors);RS0016,RS0017 diff --git a/src/Mono.Android/PublicAPI/API-34/PublicAPI.Unshipped.txt b/src/Mono.Android/PublicAPI/API-34/PublicAPI.Unshipped.txt index 4b0aea8a008..cdec2d9529d 100644 --- a/src/Mono.Android/PublicAPI/API-34/PublicAPI.Unshipped.txt +++ b/src/Mono.Android/PublicAPI/API-34/PublicAPI.Unshipped.txt @@ -8448,6 +8448,8 @@ Android.Content.Context.ObtainStyledAttributes(Android.Util.IAttributeSet? set, Android.Content.Context.ObtainStyledAttributes(Android.Util.IAttributeSet? set, int[]! attrs, int defStyleAttr, int defStyleRes) -> Android.Content.Res.TypedArray! Android.Content.Context.ObtainStyledAttributes(int resid, int[]! attrs) -> Android.Content.Res.TypedArray! Android.Content.Context.ObtainStyledAttributes(int[]! attrs) -> Android.Content.Res.TypedArray! +Android.Content.Context.RegisterReceiver(Android.Content.BroadcastReceiver? receiver, Android.Content.IntentFilter? filter, Android.Content.ReceiverFlags flags) -> Android.Content.Intent? +Android.Content.Context.RegisterReceiver(Android.Content.BroadcastReceiver? receiver, Android.Content.IntentFilter? filter, string? broadcastPermission, Android.OS.Handler? scheduler, Android.Content.ReceiverFlags flags) -> Android.Content.Intent? Android.Content.Context.StartActivity(System.Type! type) -> void Android.Content.ContextParams Android.Content.ContextParams.AttributionTag.get -> string? diff --git a/src/Mono.Android/metadata b/src/Mono.Android/metadata index 31c85dc9e61..0ca93013863 100644 --- a/src/Mono.Android/metadata +++ b/src/Mono.Android/metadata @@ -1809,6 +1809,14 @@ ModelDownloadErrorEventArgs + + + This method has an incorrect enumeration type. Use the overload that takes ReceiverFlags instead. + This method has an incorrect enumeration type. Use the overload that takes ReceiverFlags instead. + This method has an incorrect enumeration type. Use the overload that takes ReceiverFlags instead. + This method has an incorrect enumeration type. Use the overload that takes ReceiverFlags instead. + This method has an incorrect enumeration type. Use the overload that takes ReceiverFlags instead. + This method has an incorrect enumeration type. Use the overload that takes ReceiverFlags instead. - 8.0.100-preview.7.23364.32 - 8.0.0-preview.7.23364.3 - 8.0.0-preview.7.23364.3 + 8.0.100-rc.1.23373.1 + 8.0.0-rc.1.23371.3 + 8.0.0-rc.1.23371.3 7.0.0-beta.22103.1 7.0.0-beta.22103.1 - 8.0.0-preview.7.23361.2 + 8.0.0-rc.1.23368.3 $(MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion) 7.0.100-rc.1.22410.7 0.11.4-alpha.23360.2 diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/Builder.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/Builder.cs index 134fff471ef..8798d7e7ffa 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/Builder.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/Builder.cs @@ -279,7 +279,7 @@ protected bool BuildInternal (string projectOrSolution, string target, string [] } if (Builder.UseDotNet) { psi.SetEnvironmentVariable ("DOTNET_MULTILEVEL_LOOKUP", "0"); - psi.SetEnvironmentVariable ("DOTNET_ROOT", TestEnvironment.DotNetPreviewDirectory); + psi.SetEnvironmentVariable ("PATH", TestEnvironment.DotNetPreviewDirectory + Path.PathSeparator + Environment.GetEnvironmentVariable ("PATH")); } psi.Arguments = args.ToString (); diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DotNetCLI.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DotNetCLI.cs index d3da05577a1..d049bcc61ee 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DotNetCLI.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DotNetCLI.cs @@ -47,7 +47,7 @@ protected bool Execute (params string [] args) p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.SetEnvironmentVariable ("DOTNET_MULTILEVEL_LOOKUP", "0"); - p.StartInfo.SetEnvironmentVariable ("DOTNET_ROOT", TestEnvironment.DotNetPreviewDirectory); + p.StartInfo.SetEnvironmentVariable ("PATH", TestEnvironment.DotNetPreviewDirectory + Path.PathSeparator + Environment.GetEnvironmentVariable ("PATH")); if (TestEnvironment.UseLocalBuildOutput) { p.StartInfo.SetEnvironmentVariable ("DOTNETSDK_WORKLOAD_MANIFEST_ROOTS", TestEnvironment.WorkloadManifestOverridePath); p.StartInfo.SetEnvironmentVariable ("DOTNETSDK_WORKLOAD_PACK_ROOTS", TestEnvironment.WorkloadPackOverridePath); From 57eedfb39a9375ec4f2655d822ced00a6a49a3f3 Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Wed, 26 Jul 2023 14:30:40 -0400 Subject: [PATCH 06/44] [ci] Remove .NET branches from classic release trigger (#8218) The "Xamarin.Android Release Definition Trigger" pipeline is used to create PRs into VS for classic Xamarin.Android, and should not run against branches that only produce .NET Android artifacts. --- build-tools/automation/azure-pipelines-release-trigger.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build-tools/automation/azure-pipelines-release-trigger.yaml b/build-tools/automation/azure-pipelines-release-trigger.yaml index d612a931238..8e197d55709 100644 --- a/build-tools/automation/azure-pipelines-release-trigger.yaml +++ b/build-tools/automation/azure-pipelines-release-trigger.yaml @@ -12,6 +12,10 @@ resources: trigger: stages: - post_build + branches: + exclude: + - main + - release/* jobs: - job: release_trigger From 042035117e4550bae313336d876bae9a78e1bff0 Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Thu, 27 Jul 2023 12:10:02 -0400 Subject: [PATCH 07/44] [ci] Fix MAUI integration test job (#8221) The new MAUI build and test job has been failing: C:\a\_work\2\s\maui\src\DotNet\Dependencies\Workloads.csproj : error NU1102: Unable to find package Microsoft.NET.Sdk.Android.Manifest-8.0.100-preview.7 with version (= 34.0.0-ci.pr.gh8185.402) [C:\a\_work\2\s\maui\src\DotNet\DotNet.csproj] This is because our main branch has bumped from .NET 8 preview.7 builds to .NET 8 rc.1 builds. We can fix this by writing our SDK band to the Microsoft.NET.Sdk.Android.Manifest item in the workload restore project. --- build-tools/automation/azure-pipelines.yaml | 6 ++++++ build-tools/scripts/DotNet.targets | 15 +++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index 733e73cdc52..21faa74c4d3 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -352,6 +352,12 @@ stages: -androidVersion $(ANDROID_PACK_VERSION) displayName: Update MAUI's Android dependency + - task: DotNetCoreCLI@2 + displayName: Update Android SDK band in Workloads.csproj + inputs: + projects: $(Build.SourcesDirectory)/xamarin-android/Xamarin.Android.sln + arguments: -t:UpdateMauiWorkloadsProj -c $(XA.Build.Configuration) --no-restore -v:n -bl:$(Build.StagingDirectory)/logs/update-maui-workloadsproj.binlog + - pwsh: ./build.ps1 --target=dotnet --configuration="$(XA.Build.Configuration)" --nugetsource="$(Build.StagingDirectory)\android-packs" --verbosity=diagnostic displayName: Install .NET retryCountOnTaskFailure: 3 diff --git a/build-tools/scripts/DotNet.targets b/build-tools/scripts/DotNet.targets index ba9d8d5f7f1..e7fd3a84a1c 100644 --- a/build-tools/scripts/DotNet.targets +++ b/build-tools/scripts/DotNet.targets @@ -2,6 +2,10 @@ <_Root>$(MSBuildThisFileDirectory)..\..\ <_BinlogPathPrefix>$(_Root)bin/Build$(Configuration)/msbuild-$([System.DateTime]::Now.ToString("yyyyMMddTHHmmss")) + false + $(_Root)..\maui + $(MauiSourcePath)\artifacts + maui-android @@ -47,15 +51,18 @@ + + + + <_TempDirectory>$(DotNetPreviewPath)..\.xa-workload-temp-$([System.IO.Path]::GetRandomFileName()) $(DotNetSdkManifestsFolder) - false - $(XamarinAndroidSourcePath)..\maui - $(MauiSourcePath)\artifacts - maui-android From 76e029f4e8b10dcafcb6b3f4366978472f2080b1 Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Thu, 27 Jul 2023 16:56:26 +0000 Subject: [PATCH 08/44] Bump to xamarin/xamarin-android-binutils/L_16.0.6-6.0.0@b38b5bab (#8220) Fixes: https://github.com/dotnet/maui/issues/14531 Changes: https://discourse.llvm.org/t/llvm-16-0-0-release/69326 Changes: https://discourse.llvm.org/t/llvm-16-0-1-release/69774 Changes: https://discourse.llvm.org/t/llvm-16-0-2-release/70107 Changes: https://discourse.llvm.org/t/16-0-3-release/70341 Changes: https://discourse.llvm.org/t/16-0-4-release/70692 Changes: https://discourse.llvm.org/t/16-0-5-release/71097 Changes: https://discourse.llvm.org/t/16-0-6-release/71344 Changes: https://github.com/xamarin/xamarin-android-binutils/compare/L_15.0.7-5.0.3...L_16.0.6-6.0.0 * xamarin/xamarin-android-binutils@b38b5ba: Don't compress Windows binaries with UPX * xamarin/xamarin-android-binutils@1ce0b28: Bump XA utils version... * xamarin/xamarin-android-binutils@f19d814: Bump LLVM version to 16.0.6 and UPX to 4.0.2 * xamarin/xamarin-android-binutils@158bbf8: Test build Bump to an LLVM toolchain based on version 16.0.6. Additionally, drop use of the UPX executable compressor, since it appears to be crashing on some Windows machines. This fixes dotnet/maui#14531. This in turn means that package and installation sizes will be larger, but it appears that the Windows NuGet package size only increases by ~8MB, while the macOS packages are roughly the same. *Installation* size will increase on Windows from ~37.5MB to ~104.6MB for the LLVM utilities `ld.exe`, `llc.exe`, `llvm-mc.exe`, and `llvm-strip.exe`. --- build-tools/installers/unix-binutils.projitems | 4 +++- .../xaprepare/xaprepare/ConfigAndData/Configurables.cs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/build-tools/installers/unix-binutils.projitems b/build-tools/installers/unix-binutils.projitems index 7844af74665..695f1d18be2 100644 --- a/build-tools/installers/unix-binutils.projitems +++ b/build-tools/installers/unix-binutils.projitems @@ -1,7 +1,7 @@ - <_LlvmLibExtension Condition=" '$(HostOS)' == 'Linux' ">so.15 + <_LlvmLibExtension Condition=" '$(HostOS)' == 'Linux' ">so.16 <_LlvmLibExtension Condition=" '$(HostOS)' == 'Darwin' ">dylib @@ -65,6 +65,7 @@ <_BinUtilsFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)$(HostOS)\binutils\lib\libLLVMInstCombine.$(_LlvmLibExtension)" /> <_BinUtilsFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)$(HostOS)\binutils\lib\libLLVMInstrumentation.$(_LlvmLibExtension)" /> <_BinUtilsFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)$(HostOS)\binutils\lib\libLLVMipo.$(_LlvmLibExtension)" /> + <_BinUtilsFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)$(HostOS)\binutils\lib\libLLVMIRPrinter.$(_LlvmLibExtension)" /> <_BinUtilsFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)$(HostOS)\binutils\lib\libLLVMIRReader.$(_LlvmLibExtension)" /> <_BinUtilsFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)$(HostOS)\binutils\lib\libLLVMLibDriver.$(_LlvmLibExtension)" /> <_BinUtilsFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)$(HostOS)\binutils\lib\libLLVMLinker.$(_LlvmLibExtension)" /> @@ -86,6 +87,7 @@ <_BinUtilsFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)$(HostOS)\binutils\lib\libLLVMSymbolize.$(_LlvmLibExtension)" /> <_BinUtilsFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)$(HostOS)\binutils\lib\libLLVMTableGenGlobalISel.$(_LlvmLibExtension)" /> <_BinUtilsFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)$(HostOS)\binutils\lib\libLLVMTableGen.$(_LlvmLibExtension)" /> + <_BinUtilsFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)$(HostOS)\binutils\lib\libLLVMTargetParser.$(_LlvmLibExtension)" /> <_BinUtilsFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)$(HostOS)\binutils\lib\libLLVMTarget.$(_LlvmLibExtension)" /> <_BinUtilsFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)$(HostOS)\binutils\lib\libLLVMTextAPI.$(_LlvmLibExtension)" /> <_BinUtilsFilesUnixSign Include="$(MicrosoftAndroidSdkOutDir)$(HostOS)\binutils\lib\libLLVMTransformUtils.$(_LlvmLibExtension)" /> diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs index c26df75a5e1..7cc03163c24 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs @@ -15,7 +15,7 @@ namespace Xamarin.Android.Prepare // partial class Configurables { - const string BinutilsVersion = "L_15.0.7-5.0.3"; + const string BinutilsVersion = "L_16.0.6-6.0.0"; const string MicrosoftOpenJDK11Version = "11.0.16"; const string MicrosoftOpenJDK11Release = "8.1"; From 8974c066ca215a3b3fd0a306d126cf808ce6680a Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Sat, 29 Jul 2023 07:47:17 -0400 Subject: [PATCH 09/44] [build] Use .NET preview to create nupkgs (#8227) Recent `make create-installers` attempts have been failing, seemingly due to recent changes to dotnet host resolution: Restored /Users/runner/work/1/s/xamarin-android/src/Microsoft.Android.Templates/Microsoft.Android.Templates.csproj (in 257 ms). 1>/Users/runner/work/1/s/xamarin-android/bin/Release/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : You must install or update .NET to run this application. [/Users/runner/work/1/s/xamarin-android/src/Microsoft.Android.Templates/Microsoft.Android.Templates.csproj] [/Users/runner/work/1/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Sdk.proj] 1>/Users/runner/work/1/s/xamarin-android/bin/Release/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : [/Users/runner/work/1/s/xamarin-android/src/Microsoft.Android.Templates/Microsoft.Android.Templates.csproj] [/Users/runner/work/1/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Sdk.proj] 1>/Users/runner/work/1/s/xamarin-android/bin/Release/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : App: /Users/runner/work/1/s/xamarin-android/bin/Release/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/bincore/csc.dll [/Users/runner/work/1/s/xamarin-android/src/Microsoft.Android.Templates/Microsoft.Android.Templates.csproj] [/Users/runner/work/1/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Sdk.proj] 1>/Users/runner/work/1/s/xamarin-android/bin/Release/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : Architecture: x64 [/Users/runner/work/1/s/xamarin-android/src/Microsoft.Android.Templates/Microsoft.Android.Templates.csproj] [/Users/runner/work/1/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Sdk.proj] 1>/Users/runner/work/1/s/xamarin-android/bin/Release/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : Framework: 'Microsoft.NETCore.App', version '8.0.0-rc.1.23371.3' (x64) [/Users/runner/work/1/s/xamarin-android/src/Microsoft.Android.Templates/Microsoft.Android.Templates.csproj] [/Users/runner/work/1/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Sdk.proj] 1>/Users/runner/work/1/s/xamarin-android/bin/Release/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : .NET location: /Users/runner/.dotnet/ [/Users/runner/work/1/s/xamarin-android/src/Microsoft.Android.Templates/Microsoft.Android.Templates.csproj] [/Users/runner/work/1/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Sdk.proj] 1>/Users/runner/work/1/s/xamarin-android/bin/Release/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : [/Users/runner/work/1/s/xamarin-android/src/Microsoft.Android.Templates/Microsoft.Android.Templates.csproj] [/Users/runner/work/1/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Sdk.proj] 1>/Users/runner/work/1/s/xamarin-android/bin/Release/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : The following frameworks were found: [/Users/runner/work/1/s/xamarin-android/src/Microsoft.Android.Templates/Microsoft.Android.Templates.csproj] [/Users/runner/work/1/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Sdk.proj] 1>/Users/runner/work/1/s/xamarin-android/bin/Release/dotnet/sdk/8.0.100-rc.1.23373.1/Roslyn/Microsoft.CSharp.Core.targets(80,5): error : 7.0.9 at [/Users/runner/.dotnet/shared/Microsoft.NETCore.App] [/Users/runner/work/1/s/xamarin-android/src/Microsoft.Android.Templates/Microsoft.Android.Templates.csproj] [/Users/runner/work/1/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Sdk.proj] Attempt to fix this by using the .NET preview version we install into bin/$(Configuration)/dotnet to build the `` target. --- build-tools/scripts/Packaging.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-tools/scripts/Packaging.mk b/build-tools/scripts/Packaging.mk index b90286490eb..30f2c5afeee 100644 --- a/build-tools/scripts/Packaging.mk +++ b/build-tools/scripts/Packaging.mk @@ -10,7 +10,7 @@ create-installers: create-nupkgs create-nupkgs: @echo Disk usage before create-nupkgs -df -h - $(call SYSTEM_DOTNET_BINLOG,create-all-packs) -t:CreateAllPacks $(topdir)/build-tools/create-packs/Microsoft.Android.Sdk.proj + $(call DOTNET_BINLOG,create-all-packs) -t:CreateAllPacks $(topdir)/build-tools/create-packs/Microsoft.Android.Sdk.proj create-pkg: $(call SYSTEM_DOTNET_BINLOG,create-pkg) /t:CreatePkg \ From 5a6e01e12f97da86a975e780883e6edf4a53ee15 Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Mon, 31 Jul 2023 10:48:15 -0400 Subject: [PATCH 10/44] [ci] Target hosted macOS-13 Ventura pool (#8215) Updates our macOS test jobs to run on the latest hosted macOS images. The [Ventura images][0] do not contain classic Xamarin or Mono packages, so these have been added to the test jobs that still require them. [0]: https://github.com/actions/runner-images/blob/96f1383301c4d6866d3186b31c52c4d84e7b8812/images/macos/macos-13-Readme.md --- .../automation/yaml-templates/install-apkdiff.yaml | 9 ++++++++- .../yaml-templates/install-dotnet-test-slicer.yaml | 9 ++++++++- .../yaml-templates/run-msbuild-tests.yaml | 1 + .../yaml-templates/setup-test-environment.yaml | 14 ++++++++++++++ .../stage-msbuild-emulator-tests.yaml | 3 ++- .../automation/yaml-templates/variables.yaml | 2 +- .../Android/AndroidSdkResolver.cs | 13 +++++++------ 7 files changed, 41 insertions(+), 10 deletions(-) diff --git a/build-tools/automation/yaml-templates/install-apkdiff.yaml b/build-tools/automation/yaml-templates/install-apkdiff.yaml index 79f79b62678..8984b80ac45 100644 --- a/build-tools/automation/yaml-templates/install-apkdiff.yaml +++ b/build-tools/automation/yaml-templates/install-apkdiff.yaml @@ -9,7 +9,14 @@ steps: ignoreLASTEXITCODE: true condition: ${{ parameters.condition }} -- script: dotnet tool update apkdiff --version ${{ parameters.version }} --add-source https://api.nuget.org/v3/index.json -g +- task: DotNetCoreCLI@2 displayName: install apkdiff ${{ parameters.version }} condition: ${{ parameters.condition }} continueOnError: ${{ parameters.continueOnError }} + inputs: + command: custom + custom: tool + arguments: >- + update apkdiff -g + --version ${{ parameters.version }} + --add-source "https://api.nuget.org/v3/index.json" diff --git a/build-tools/automation/yaml-templates/install-dotnet-test-slicer.yaml b/build-tools/automation/yaml-templates/install-dotnet-test-slicer.yaml index 219d01d8ec7..8f2080abe3c 100644 --- a/build-tools/automation/yaml-templates/install-dotnet-test-slicer.yaml +++ b/build-tools/automation/yaml-templates/install-dotnet-test-slicer.yaml @@ -9,7 +9,14 @@ steps: ignoreLASTEXITCODE: true condition: ${{ parameters.condition }} -- script: dotnet tool update dotnet-test-slicer --version ${{ parameters.version }} --add-source https://api.nuget.org/v3/index.json -g +- task: DotNetCoreCLI@2 displayName: install dotnet-test-slicer ${{ parameters.version }} condition: ${{ parameters.condition }} continueOnError: ${{ parameters.continueOnError }} + inputs: + command: custom + custom: tool + arguments: >- + update dotnet-test-slicer -g + --version ${{ parameters.version }} + --add-source "https://api.nuget.org/v3/index.json" diff --git a/build-tools/automation/yaml-templates/run-msbuild-tests.yaml b/build-tools/automation/yaml-templates/run-msbuild-tests.yaml index 9d391d2de82..908049e9c47 100644 --- a/build-tools/automation/yaml-templates/run-msbuild-tests.yaml +++ b/build-tools/automation/yaml-templates/run-msbuild-tests.yaml @@ -33,6 +33,7 @@ jobs: parameters: installTestSlicer: true installLegacyDotNet: false + installLegacyXamarinAndroid: true restoreNUnitConsole: false updateMono: false xaSourcePath: ${{ parameters.xaSourcePath }} diff --git a/build-tools/automation/yaml-templates/setup-test-environment.yaml b/build-tools/automation/yaml-templates/setup-test-environment.yaml index 3d50467c960..34602aedfed 100644 --- a/build-tools/automation/yaml-templates/setup-test-environment.yaml +++ b/build-tools/automation/yaml-templates/setup-test-environment.yaml @@ -7,6 +7,7 @@ parameters: installTestSlicer: false installApkDiff: true installLegacyDotNet: true + installLegacyXamarinAndroid: false restoreNUnitConsole: true updateMono: true androidSdkPlatforms: $(DefaultTestSdkPlatforms) @@ -66,6 +67,19 @@ steps: condition: and(succeeded(), eq(variables['agent.os'], 'Darwin')) xaSourcePath: ${{ parameters.xaSourcePath }} +- ${{ if eq(parameters.installLegacyXamarinAndroid, true) }}: + - task: DotNetCoreCLI@2 + displayName: install boots 1.1.0.36 + inputs: + command: custom + custom: tool + arguments: >- + update boots -g + --version 1.1.0.36 + --add-source "https://api.nuget.org/v3/index.json" + - powershell: boots --stable Xamarin.Android + displayName: install Xamarin.Android stable + - template: run-xaprepare.yaml parameters: arguments: --s=${{ parameters.xaprepareScenario }} --android-sdk-platforms="${{ parameters.androidSdkPlatforms }}" diff --git a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml index a6eeba08f25..202d6fd696a 100644 --- a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml @@ -36,8 +36,9 @@ stages: installTestSlicer: true installApkDiff: false installLegacyDotNet: false + installLegacyXamarinAndroid: true restoreNUnitConsole: false - updateMono: false + updateMono: true xaSourcePath: ${{ parameters.xaSourcePath }} repositoryAlias: ${{ parameters.repositoryAlias }} commit: ${{ parameters.commit }} diff --git a/build-tools/automation/yaml-templates/variables.yaml b/build-tools/automation/yaml-templates/variables.yaml index 611f20feed5..41045ca8d6f 100644 --- a/build-tools/automation/yaml-templates/variables.yaml +++ b/build-tools/automation/yaml-templates/variables.yaml @@ -24,7 +24,7 @@ variables: - name: GitHub.Token value: $(github--pat--vs-mobiletools-engineering-service2) - name: HostedMacImage - value: macOS-12 + value: macOS-13 - name: HostedWinImage value: windows-2022 - name: 1ESWindowsPool diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidSdkResolver.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidSdkResolver.cs index ff7e491d51f..f3e5a4703d6 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidSdkResolver.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/AndroidSdkResolver.cs @@ -48,12 +48,12 @@ public static string GetAndroidNdkPath () public static string GetJavaSdkPath () { var javaSdkPath = Environment.GetEnvironmentVariable ("TEST_ANDROID_JDK_PATH"); - if (string.IsNullOrEmpty (javaSdkPath)) - javaSdkPath = JavaSdkPath ??= RunPathsTargets ("GetJavaSdkDirectory"); if (string.IsNullOrEmpty (javaSdkPath)) javaSdkPath = JavaSdkPath ??= Environment.GetEnvironmentVariable ("JI_JAVA_HOME"); if (string.IsNullOrEmpty (javaSdkPath)) javaSdkPath = JavaSdkPath ??= Environment.GetEnvironmentVariable ("JAVA_HOME"); + if (string.IsNullOrEmpty (javaSdkPath)) + javaSdkPath = JavaSdkPath ??= RunPathsTargets ("GetJavaSdkDirectory"); if (string.IsNullOrEmpty (javaSdkPath)) javaSdkPath = JavaSdkPath ??= GetPathFromRegistry ("JavaSdkDirectory"); if (string.IsNullOrEmpty (javaSdkPath)) @@ -88,17 +88,18 @@ public static string GetJavaSdkVersionString () static string RunPathsTargets (string target) { var targets = Path.Combine (XABuildPaths.TopDirectory, "build-tools", "scripts", "Paths.targets"); - var msbuild = TestEnvironment.IsWindows ? TestEnvironment.GetVisualStudioInstance ().MSBuildPath : "msbuild"; - var args = $"/nologo /v:minimal /t:{target} \"{targets}\""; - var psi = new ProcessStartInfo (msbuild, args) { + var dotnet = Path.Combine (TestEnvironment.DotNetPreviewDirectory, "dotnet"); + var args = $"build /nologo /v:minimal /t:{target} \"{targets}\""; + var psi = new ProcessStartInfo (dotnet, args) { CreateNoWindow = true, RedirectStandardOutput = true, WindowStyle = ProcessWindowStyle.Hidden, UseShellExecute = false, + WorkingDirectory = XABuildPaths.TestAssemblyOutputDirectory, }; using (var p = Process.Start (psi)) { p.WaitForExit (); - string path = p.StandardOutput.ReadToEnd ().Trim (); + string path = p.StandardOutput.ReadLine ().Trim (); return Directory.Exists (path) ? path : null; } } From d14db82efe2b7dab55ec77c10574916e85dfe555 Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Mon, 31 Jul 2023 11:21:03 -0400 Subject: [PATCH 11/44] [ci] Run Codesign Verify task against new MSI folder (#8226) Fixes the codesign validation task to run against all of the outputs of the workload MSI generation task. --- build-tools/automation/azure-pipelines.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index 21faa74c4d3..bb281547047 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -470,7 +470,9 @@ stages: - task: MicroBuildCodesignVerify@3 displayName: verify signed msi content inputs: - TargetFolders: $(Build.StagingDirectory)\bin\manifests + TargetFolders: | + $(Build.ArtifactStagingDirectory)\bin\manifests + $(Build.ArtifactStagingDirectory)\bin\manifests-multitarget ExcludeSNVerify: true ApprovalListPathForCerts: $(Build.StagingDirectory)\sign-verify\SignVerifyIgnore.txt From 35c1e70a7133a31f92849aca44a683306892c93a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Jul 2023 14:08:27 -0400 Subject: [PATCH 12/44] Bump to xamarin/Java.Interop/main@62efc098 (#8201) Context: https://github.com/dotnet/runtime/issues/89190 Context: https://github.com/xamarin/xamarin-android/pull/8176 Changes: https://github.com/xamarin/java.interop/compare/151b03ee1eefa62e3d29b034b2aaf05ea73d99ed...62efc09806d6d2ed1cac34611acb070856d53f02 * xamarin/java.interop@62efc098: [tests] add category for tests that fail under LLVM (xamarin/java.interop#1131) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> From 16e0943f5af8774d3b7cc93535333222ed6d78a7 Mon Sep 17 00:00:00 2001 From: "microsoft-github-policy-service[bot]" <77245923+microsoft-github-policy-service[bot]@users.noreply.github.com> Date: Mon, 31 Jul 2023 14:47:59 -0400 Subject: [PATCH 13/44] [ci] use GitOps.ResourceManagement, as FabricBot is decommissioned (#8173) Context: fb89198f7f9a583c546fb02cce5c9be78402bf20 Context: a0377cdae565e361100b891fe171a5aa49778207 Context: 39183370b98b3afaa0211c8c61de923bde537941 Context: https://aka.ms/gim/fabricbot Context: https://microsoft.github.io/GitOps/policies/resource-management.html Migrate away from `fabricbot.json` (fb89198f, a0377cda, 39183370) to `.github/policies/resourceManagement.yml` Co-authored-by: microsoft-github-policy-service[bot] <77245923+microsoft-github-policy-service[bot]@users.noreply.github.com> --- .github/fabricbot.json | 764 ------------------------ .github/policies/resourceManagement.yml | 109 ++++ 2 files changed, 109 insertions(+), 764 deletions(-) delete mode 100644 .github/fabricbot.json create mode 100644 .github/policies/resourceManagement.yml diff --git a/.github/fabricbot.json b/.github/fabricbot.json deleted file mode 100644 index 92ca89b1772..00000000000 --- a/.github/fabricbot.json +++ /dev/null @@ -1,764 +0,0 @@ -{ - "version": "1.0", - "tasks": [ - { - "taskType": "trigger", - "capabilityId": "IssueResponder", - "subCapability": "IssuesOnlyResponder", - "version": "1.0", - "config": { - "conditions": { - "operator": "and", - "operands": [ - { - "name": "labelAdded", - "parameters": { - "label": "need-info" - } - } - ] - }, - "eventType": "issue", - "eventNames": [ - "issues", - "project_card" - ], - "taskName": "Add comment when 'need-info' is applied to issue", - "actions": [ - { - "name": "addReply", - "parameters": { - "comment": "Hi @${issueAuthor}. We have added the \"need-info\" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time." - } - } - ] - } - }, - { - "taskType": "scheduled", - "capabilityId": "ScheduledSearch", - "subCapability": "ScheduledSearch", - "version": "1.1", - "config": { - "frequency": [ - { - "weekDay": 1, - "hours": [ - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23 - ], - "timezoneOffset": -5 - }, - { - "weekDay": 2, - "hours": [ - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23 - ], - "timezoneOffset": -5 - }, - { - "weekDay": 3, - "hours": [ - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23 - ], - "timezoneOffset": -5 - }, - { - "weekDay": 4, - "hours": [ - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23 - ], - "timezoneOffset": -5 - }, - { - "weekDay": 5, - "hours": [ - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23 - ], - "timezoneOffset": -5 - } - ], - "searchTerms": [ - { - "name": "isIssue", - "parameters": {} - }, - { - "name": "isOpen", - "parameters": {} - }, - { - "name": "hasLabel", - "parameters": { - "label": "need-info" - } - }, - { - "name": "noActivitySince", - "parameters": { - "days": 7 - } - } - ], - "taskName": "[Idle Issue Management] Close stale 'need-info' issues", - "actions": [ - { - "name": "addReply", - "parameters": { - "comment": "Hi @${issueAuthor}. Due to inactivity, we will be closing this issue. Please feel free to re-open this issue if the issue persists. For enhanced visibility, if over 7 days have passed, please open a new issue and link this issue there. Thank you." - } - }, - { - "name": "closeIssue", - "parameters": {} - } - ] - } - }, - { - "taskType": "trigger", - "capabilityId": "IssueResponder", - "subCapability": "IssueCommentResponder", - "version": "1.0", - "config": { - "conditions": { - "operator": "and", - "operands": [ - { - "name": "isAction", - "parameters": { - "action": "created" - } - }, - { - "name": "isOpen", - "parameters": {} - }, - { - "name": "hasLabel", - "parameters": { - "label": "need-info" - } - }, - { - "operator": "not", - "operands": [ - { - "name": "activitySenderHasPermissions", - "parameters": { - "permissions": "admin" - } - } - ] - }, - { - "operator": "not", - "operands": [ - { - "name": "activitySenderHasPermissions", - "parameters": { - "permissions": "write" - } - } - ] - } - ] - }, - "eventType": "issue", - "eventNames": [ - "issue_comment" - ], - "taskName": "[Idle Issue Management] Replace 'need-info' with 'need-attention' label when the customer comments on an issue", - "actions": [ - { - "name": "removeLabel", - "parameters": { - "label": "need-info" - } - }, - { - "name": "addLabel", - "parameters": { - "label": "need-attention" - } - } - ] - } - }, - { - "taskType": "trigger", - "capabilityId": "IssueResponder", - "subCapability": "IssueCommentResponder", - "version": "1.0", - "config": { - "conditions": { - "operator": "and", - "operands": [ - { - "operator": "not", - "operands": [ - { - "name": "isOpen", - "parameters": {} - } - ] - }, - { - "name": "isAction", - "parameters": { - "action": "created" - } - }, - { - "operator": "not", - "operands": [ - { - "name": "noActivitySince", - "parameters": { - "days": 7 - } - } - ] - }, - { - "operator": "not", - "operands": [ - { - "name": "isCloseAndComment", - "parameters": {} - } - ] - }, - { - "name": "isActivitySender", - "parameters": { - "user": { - "type": "author" - } - } - }, - { - "name": "activitySenderHasPermissions", - "parameters": { - "permissions": "none" - } - }, - { - "name": "hasLabel", - "parameters": { - "label": "need-info" - } - } - ] - }, - "eventType": "issue", - "eventNames": [ - "issue_comment" - ], - "taskName": "[Idle Issue Management] For issues closed due to inactivity, re-open an issue if issue author posts a reply within 7 days.", - "actions": [ - { - "name": "reopenIssue", - "parameters": {} - }, - { - "name": "removeLabel", - "parameters": { - "label": "need-info" - } - }, - { - "name": "addLabel", - "parameters": { - "label": "need-attention" - } - } - ] - } - }, - { - "taskType": "trigger", - "capabilityId": "IssueResponder", - "subCapability": "IssueCommentResponder", - "version": "1.0", - "config": { - "conditions": { - "operator": "and", - "operands": [ - { - "name": "isAction", - "parameters": { - "action": "created" - } - }, - { - "operator": "not", - "operands": [ - { - "name": "isOpen", - "parameters": {} - } - ] - }, - { - "name": "activitySenderHasPermissions", - "parameters": { - "permissions": "none" - } - }, - { - "name": "noActivitySince", - "parameters": { - "days": 7 - } - }, - { - "operator": "not", - "operands": [ - { - "name": "isCloseAndComment", - "parameters": {} - } - ] - } - ] - }, - "eventType": "issue", - "eventNames": [ - "issue_comment" - ], - "taskName": "[Closed Issue Management] For issues closed with no activity over 7 days, ask non-contributor to consider opening a new issue instead.", - "actions": [ - { - "name": "addReply", - "parameters": { - "comment": "Hello lovely human, thank you for your comment on this issue. Because this issue has been closed for a period of time, please strongly consider opening a new issue linking to this issue instead to ensure better visibility of your comment. Thank you!" - } - } - ] - } - }, - { - "taskType": "scheduled", - "capabilityId": "ScheduledSearch", - "subCapability": "ScheduledSearch", - "version": "1.1", - "config": { - "frequency": [ - { - "weekDay": 0, - "hours": [ - 10, - 22 - ], - "timezoneOffset": -5 - }, - { - "weekDay": 1, - "hours": [ - 10, - 22 - ], - "timezoneOffset": -5 - }, - { - "weekDay": 2, - "hours": [ - 10, - 22 - ], - "timezoneOffset": -5 - }, - { - "weekDay": 3, - "hours": [ - 10, - 22 - ], - "timezoneOffset": -5 - }, - { - "weekDay": 4, - "hours": [ - 10, - 22 - ], - "timezoneOffset": -5 - }, - { - "weekDay": 5, - "hours": [ - 10, - 22 - ], - "timezoneOffset": -5 - }, - { - "weekDay": 6, - "hours": [ - 10, - 22 - ], - "timezoneOffset": -5 - } - ], - "searchTerms": [ - { - "name": "isClosed", - "parameters": {} - }, - { - "name": "noActivitySince", - "parameters": { - "days": 30 - } - }, - { - "name": "isUnlocked", - "parameters": {} - }, - { - "name": "isIssue", - "parameters": {} - } - ], - "taskName": "[Closed Issue Management] Lock issues closed without activity for over 30 days", - "actions": [ - { - "name": "lockIssue", - "parameters": { - "reason": "resolved" - } - } - ] - } - }, - { - "taskType": "trigger", - "capabilityId": "IssueResponder", - "subCapability": "IssuesOnlyResponder", - "version": "1.0", - "config": { - "conditions": { - "operator": "and", - "operands": [ - { - "name": "isAction", - "parameters": { - "action": "opened" - } - } - ] - }, - "eventType": "issue", - "eventNames": [ - "issues", - "project_card" - ], - "actions": [ - { - "name": "addLabel", - "parameters": { - "label": "needs-triage" - } - } - ], - "taskName": "[New Issues] Apply 'needs-triage' to new issues" - } - }, - { - "taskType": "trigger", - "capabilityId": "IssueResponder", - "subCapability": "IssuesOnlyResponder", - "version": "1.0", - "config": { - "conditions": { - "operator": "and", - "operands": [ - { - "name": "labelAdded", - "parameters": { - "label": "possibly-stale" - } - } - ] - }, - "eventType": "issue", - "eventNames": [ - "issues", - "project_card" - ], - "taskName": "Manual Issue Cleanup", - "actions": [ - { - "name": "addReply", - "parameters": { - "comment": "We suspect this issue is stale and no longer relevant. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process." - } - } - ] - } - }, - { - "taskType": "trigger", - "capabilityId": "IssueResponder", - "subCapability": "IssueCommentResponder", - "version": "1.0", - "config": { - "conditions": { - "operator": "and", - "operands": [ - { - "name": "hasLabel", - "parameters": { - "label": "possibly-stale" - } - } - ] - }, - "eventType": "issue", - "eventNames": [ - "issue_comment" - ], - "taskName": "Remove `possibly-stale` label when an issue is commented on", - "actions": [ - { - "name": "removeLabel", - "parameters": { - "label": "possibly-stale" - } - }, - { - "name": "addLabel", - "parameters": { - "label": "need-attention" - } - } - ] - } - }, - { - "taskType": "scheduled", - "capabilityId": "ScheduledSearch", - "subCapability": "ScheduledSearch", - "version": "1.1", - "config": { - "frequency": [ - { - "weekDay": 0, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 1, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 2, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 3, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 4, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 5, - "hours": [ - 0, - 6, - 12, - 18 - ] - }, - { - "weekDay": 6, - "hours": [ - 0, - 6, - 12, - 18 - ] - } - ], - "searchTerms": [ - { - "name": "isIssue", - "parameters": {} - }, - { - "name": "isOpen", - "parameters": {} - }, - { - "name": "hasLabel", - "parameters": { - "label": "possibly-stale" - } - }, - { - "name": "noActivitySince", - "parameters": { - "days": 14 - } - } - ], - "taskName": "Close 'possibly-stale' issues with no recent activity", - "actions": [ - { - "name": "addReply", - "parameters": { - "comment": "This issue will now be closed since it had been marked `possibly-stale` but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days." - } - }, - { - "name": "closeIssue", - "parameters": {} - } - ] - } - } - ], - "userGroups": [] -} \ No newline at end of file diff --git a/.github/policies/resourceManagement.yml b/.github/policies/resourceManagement.yml new file mode 100644 index 00000000000..358ce894cbf --- /dev/null +++ b/.github/policies/resourceManagement.yml @@ -0,0 +1,109 @@ +id: +name: GitOps.PullRequestIssueManagement +description: GitOps.PullRequestIssueManagement primitive +owner: +resource: repository +disabled: false +where: +configuration: + resourceManagementConfiguration: + scheduledSearches: + - description: + frequencies: + - weekday: + day: Monday + time: 0:0 + - weekday: + day: Tuesday + time: 0:0 + - weekday: + day: Wednesday + time: 0:0 + - weekday: + day: Thursday + time: 0:0 + - weekday: + day: Friday + time: 0:0 + filters: + - isIssue + - isOpen + - hasLabel: + label: need-info + - noActivitySince: + days: 7 + actions: + - addReply: + reply: Hi @${issueAuthor}. Due to inactivity, we will be closing this issue. Please feel free to re-open this issue if the issue persists. For enhanced visibility, if over 7 days have passed, please open a new issue and link this issue there. Thank you. + - closeIssue + - description: + frequencies: + - hourly: + hour: 6 + filters: + - isIssue + - isOpen + - hasLabel: + label: possibly-stale + - noActivitySince: + days: 14 + actions: + - addReply: + reply: This issue will now be closed since it had been marked `possibly-stale` but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days. + - closeIssue + eventResponderTasks: + - if: + - payloadType: Issues + - labelAdded: + label: need-info + then: + - addReply: + reply: Hi @${issueAuthor}. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. + description: + - if: + - payloadType: Issue_Comment + - isAction: + action: Created + - isOpen + - hasLabel: + label: need-info + - not: + activitySenderHasPermission: + permission: Admin + - not: + activitySenderHasPermission: + permission: Write + then: + - removeLabel: + label: need-info + - addLabel: + label: need-attention + description: + - if: + - payloadType: Issues + - isAction: + action: Opened + then: + - addLabel: + label: needs-triage + description: + - if: + - payloadType: Issues + - labelAdded: + label: possibly-stale + then: + - addReply: + reply: We suspect this issue is stale and no longer relevant. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process. + description: + - if: + - payloadType: Issue_Comment + - hasLabel: + label: possibly-stale + then: + - removeLabel: + label: possibly-stale + - addLabel: + label: need-attention + description: +onFailure: +onSuccess: From e803904fd32df214fcacfb7b6b66a8e3dc2dddea Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Mon, 31 Jul 2023 21:02:34 -0400 Subject: [PATCH 14/44] Bump to dotnet/installer@7168a85a60 8.0.100-rc.1.23380.2 (#8229) Changes: https://github.com/dotnet/installer/compare/f8bab721ae...7168a85a60 Changes: https://github.com/dotnet/runtime/compare/f016dc4b7c...ea97babd7c Updates: * Microsoft.Dotnet.Sdk.Internal: from 8.0.100-rc.1.23373.1 to 8.0.100-rc.1.23380.2 * Microsoft.NETCore.App.Ref: from 8.0.0-rc.1.23371.3 to 8.0.0-rc.1.23376.5 * Microsoft.NET.ILLink.Tasks: from 8.0.0-rc.1.23371.3 to 8.0.0-rc.1.23376.5 --- eng/Version.Details.xml | 12 ++++++------ eng/Versions.props | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 5142c386f40..20bcdd23fca 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -1,16 +1,16 @@ - + https://github.com/dotnet/installer - f8bab721aec4cce610504674cd08d68048250f19 + 7168a85a60a483aa627c9f1bdc1cc12546253017 - + https://github.com/dotnet/runtime - f016dc4b7cfc306d2d5e29c49e5ccd2d2916d466 + ea97babd7ccfd2f6e9553093d315f26b51e4c7ac - + https://github.com/dotnet/runtime - f016dc4b7cfc306d2d5e29c49e5ccd2d2916d466 + ea97babd7ccfd2f6e9553093d315f26b51e4c7ac https://github.com/dotnet/emsdk diff --git a/eng/Versions.props b/eng/Versions.props index cfbb80d8832..88258ec35f8 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -1,9 +1,9 @@ - 8.0.100-rc.1.23373.1 - 8.0.0-rc.1.23371.3 - 8.0.0-rc.1.23371.3 + 8.0.100-rc.1.23380.2 + 8.0.0-rc.1.23376.5 + 8.0.0-rc.1.23376.5 7.0.0-beta.22103.1 7.0.0-beta.22103.1 8.0.0-rc.1.23368.3 From 964d2a2e9f59ea2daaaa5af3b5033cabc6316740 Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Tue, 1 Aug 2023 12:43:16 -0400 Subject: [PATCH 15/44] [ci] Fix condition for MAUI integration test job (#8232) This test job should only run if the initial build was successful. --- build-tools/automation/azure-pipelines.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index bb281547047..cbe71e524d5 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -292,7 +292,7 @@ stages: - stage: maui_tests displayName: MAUI Tests dependsOn: mac_build - condition: eq(variables['System.PullRequest.TargetBranch'], 'main') + condition: and(eq(dependencies.mac_build.result, 'Succeeded'), eq(variables['System.PullRequest.TargetBranch'], 'main')) jobs: # Check - "Xamarin.Android (MAUI Tests MAUI Integration)" - job: maui_tests_integration From 80a4716ebba248cd2f1a918259e238f1151c535c Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Tue, 1 Aug 2023 13:33:05 -0400 Subject: [PATCH 16/44] [ci] Add install-global-tool yaml template (#8233) Attempts to install the boots global tool have been failing: "C:\Program Files\dotnet\dotnet.exe" tool update boots -g --version 1.1.0.36 --add-source https://api.nuget.org/v3/index.json The requested version 1.1.0.36 is lower than existing version 1.1.0.712-preview2. Fix this by replacing the install-apkdiff and install-dotnet-test-slicer templates with a generic install-global-tool template that is also used to install boots. --- .../yaml-templates/build-windows.yaml | 5 +++- .../install-dotnet-test-slicer.yaml | 22 ----------------- ...-apkdiff.yaml => install-global-tool.yaml} | 11 +++++---- .../setup-test-environment.yaml | 24 ++++++++++--------- .../automation/yaml-templates/variables.yaml | 6 +++++ 5 files changed, 29 insertions(+), 39 deletions(-) delete mode 100644 build-tools/automation/yaml-templates/install-dotnet-test-slicer.yaml rename build-tools/automation/yaml-templates/{install-apkdiff.yaml => install-global-tool.yaml} (61%) diff --git a/build-tools/automation/yaml-templates/build-windows.yaml b/build-tools/automation/yaml-templates/build-windows.yaml index b94bb97c15b..485ab749bdf 100644 --- a/build-tools/automation/yaml-templates/build-windows.yaml +++ b/build-tools/automation/yaml-templates/build-windows.yaml @@ -86,7 +86,10 @@ stages: displayName: Build Solution continueOnError: false - - template: install-apkdiff.yaml + - template: install-global-tool.yaml + parameters: + toolName: apkdiff + version: $(ApkDiffToolVersion) - template: run-nunit-tests.yaml parameters: diff --git a/build-tools/automation/yaml-templates/install-dotnet-test-slicer.yaml b/build-tools/automation/yaml-templates/install-dotnet-test-slicer.yaml deleted file mode 100644 index 8f2080abe3c..00000000000 --- a/build-tools/automation/yaml-templates/install-dotnet-test-slicer.yaml +++ /dev/null @@ -1,22 +0,0 @@ -parameters: - version: '0.1.0-alpha5' - condition: succeeded() - continueOnError: true - -steps: -- powershell: dotnet tool uninstall dotnet-test-slicer -g - displayName: uninstall dotnet-test-slicer - ignoreLASTEXITCODE: true - condition: ${{ parameters.condition }} - -- task: DotNetCoreCLI@2 - displayName: install dotnet-test-slicer ${{ parameters.version }} - condition: ${{ parameters.condition }} - continueOnError: ${{ parameters.continueOnError }} - inputs: - command: custom - custom: tool - arguments: >- - update dotnet-test-slicer -g - --version ${{ parameters.version }} - --add-source "https://api.nuget.org/v3/index.json" diff --git a/build-tools/automation/yaml-templates/install-apkdiff.yaml b/build-tools/automation/yaml-templates/install-global-tool.yaml similarity index 61% rename from build-tools/automation/yaml-templates/install-apkdiff.yaml rename to build-tools/automation/yaml-templates/install-global-tool.yaml index 8984b80ac45..69ac8c28583 100644 --- a/build-tools/automation/yaml-templates/install-apkdiff.yaml +++ b/build-tools/automation/yaml-templates/install-global-tool.yaml @@ -1,22 +1,23 @@ parameters: - version: '0.0.15' + toolName: '' + version: '' condition: succeeded() continueOnError: true steps: -- powershell: dotnet tool uninstall apkdiff -g - displayName: uninstall apkdiff +- powershell: dotnet tool uninstall ${{ parameters.toolName }} -g + displayName: uninstall ${{ parameters.toolName }} ignoreLASTEXITCODE: true condition: ${{ parameters.condition }} - task: DotNetCoreCLI@2 - displayName: install apkdiff ${{ parameters.version }} + displayName: install ${{ parameters.toolName }} ${{ parameters.version }} condition: ${{ parameters.condition }} continueOnError: ${{ parameters.continueOnError }} inputs: command: custom custom: tool arguments: >- - update apkdiff -g + update ${{ parameters.toolName }} -g --version ${{ parameters.version }} --add-source "https://api.nuget.org/v3/index.json" diff --git a/build-tools/automation/yaml-templates/setup-test-environment.yaml b/build-tools/automation/yaml-templates/setup-test-environment.yaml index 34602aedfed..6b98286ab37 100644 --- a/build-tools/automation/yaml-templates/setup-test-environment.yaml +++ b/build-tools/automation/yaml-templates/setup-test-environment.yaml @@ -68,15 +68,11 @@ steps: xaSourcePath: ${{ parameters.xaSourcePath }} - ${{ if eq(parameters.installLegacyXamarinAndroid, true) }}: - - task: DotNetCoreCLI@2 - displayName: install boots 1.1.0.36 - inputs: - command: custom - custom: tool - arguments: >- - update boots -g - --version 1.1.0.36 - --add-source "https://api.nuget.org/v3/index.json" + - template: install-global-tool.yaml + parameters: + toolName: boots + version: $(BootsToolVersion) + continueOnError: false - powershell: boots --stable Xamarin.Android displayName: install Xamarin.Android stable @@ -120,7 +116,13 @@ steps: arguments: -t:ExtractWorkloadPacks -c ${{ parameters.configuration }} -v:n -bl:${{ parameters.xaSourcePath }}/bin/Test${{ parameters.configuration }}/extract-workloads.binlog - ${{ if eq(parameters.installApkDiff, true) }}: - - template: install-apkdiff.yaml + - template: install-global-tool.yaml + parameters: + toolName: apkdiff + version: $(ApkDiffToolVersion) - ${{ if eq(parameters.installTestSlicer, true) }}: - - template: install-dotnet-test-slicer.yaml + - template: install-global-tool.yaml + parameters: + toolName: dotnet-test-slicer + version: $(TestSlicerToolVersion) diff --git a/build-tools/automation/yaml-templates/variables.yaml b/build-tools/automation/yaml-templates/variables.yaml index 41045ca8d6f..41c64201b08 100644 --- a/build-tools/automation/yaml-templates/variables.yaml +++ b/build-tools/automation/yaml-templates/variables.yaml @@ -13,6 +13,12 @@ variables: value: test-assemblies - name: WindowsToolchainPdbArtifactName value: windows-toolchain-pdb +- name: ApkDiffToolVersion + value: 0.0.15 +- name: TestSlicerToolVersion + value: 0.1.0-alpha5 +- name: BootsToolVersion + value: 1.1.0.36 - name: NUnitConsoleVersion value: 3.16.3 - name: NUnit.NumberOfTestWorkers From ae4f229c6a43a2e57fa801a136c8697dcfbc2ca1 Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Wed, 2 Aug 2023 12:26:32 -0400 Subject: [PATCH 17/44] [tests] Remove duplicates from XASdkTests (#8214) I've spent some time reviewing tests in `XASdkTests`, `BuildTest`, and `BuildTest2`. Tests from `XASdkTests` have been migrated to other fixtures or removed where applicable. * DotNetBuildXamarinForms has been removed and merged into CheckMonoComponentsMask. * DotNetIncremental has been removed and merged into BuildIncrementalAot. * DotNetDesignTimeBuild has been renamed to DesignTimeBuildSignAndroidPackage. * BenchmarkDotNet has been removed and merged into BuildHasNoWarnings. * BuildApplicationWithJavaSource has been removed due to existing coverage of .java file inclusion elsewhere. * BuildReleaseApplicationWithNugetPackages has been removed due to existing coverage in GenerateLibraryResourcesTests. * BuildAfterAddingNuget has been removed as the same scenario is covered in BuildAfterUpgradingNuget. * ValidateJavaVersion has been removed as .NET Android requires JDK 11+, which is not covered by any of the legacy parameters. --- .../AndroidUpdateResourcesTest.cs | 45 + .../Xamarin.Android.Build.Tests/AotTests.cs | 42 + .../BindingBuildTest.cs | 84 +- .../BuildTest.TestCaseSource.cs | 99 ++ .../Xamarin.Android.Build.Tests/BuildTest.cs | 933 +++------------ .../Xamarin.Android.Build.Tests/BuildTest2.cs | 1 + .../BuildWithLibraryTests.cs | 887 ++++++++++++++ .../IncrementalBuildTest.cs | 57 +- .../InvalidConfigTests.cs | 114 ++ .../PackagingTest.cs | 41 + .../Xamarin.Android.Build.Tests/WearTests.cs | 25 + .../Xamarin.Android.Build.Tests/XASdkTests.cs | 1017 +---------------- 12 files changed, 1537 insertions(+), 1808 deletions(-) create mode 100644 src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildWithLibraryTests.cs create mode 100644 src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/InvalidConfigTests.cs diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidUpdateResourcesTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidUpdateResourcesTest.cs index dd811c1d880..c653639bfd0 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidUpdateResourcesTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidUpdateResourcesTest.cs @@ -6,6 +6,7 @@ using System.Text.RegularExpressions; using System.Xml.Linq; using Microsoft.Build.Framework; +using Mono.Cecil; using NUnit.Framework; using Xamarin.Android.Tools; using Xamarin.ProjectTools; @@ -648,6 +649,50 @@ public void CheckOldResourceDesignerWithWrongCasingIsRemoved ([Values (true, fal } } + [Test] + public void GenerateResourceDesigner_false([Values (false, true)] bool useDesignerAssembly) + { + var proj = new XamarinAndroidApplicationProject { + EnableDefaultItems = true, + Sources = { + new AndroidItem.AndroidResource (() => "Resources\\drawable\\foo.png") { + BinaryContent = () => XamarinAndroidCommonProject.icon_binary_mdpi, + }, + } + }; + proj.SetProperty (KnownProperties.OutputType, "Library"); + + // Turn off Resource.designer.cs and remove usage of it + proj.SetProperty ("AndroidGenerateResourceDesigner", "false"); + if (!useDesignerAssembly) + proj.SetProperty ("AndroidUseDesignerAssembly", "false"); + proj.MainActivity = proj.DefaultMainActivity + .Replace ("Resource.Layout.Main", "0") + .Replace ("Resource.Id.myButton", "0"); + + var builder = CreateDllBuilder (); + Assert.IsTrue (builder.RunTarget(proj, "CoreCompile", parameters: new string[] { "BuildingInsideVisualStudio=true" }), "Designtime build should succeed."); + var intermediate = Path.Combine (Root, builder.ProjectDirectory, proj.IntermediateOutputPath); + var resource_designer_cs = Path.Combine (intermediate, "designtime", "Resource.designer.cs"); + if (useDesignerAssembly) + resource_designer_cs = Path.Combine (intermediate, "__Microsoft.Android.Resource.Designer.cs"); + FileAssert.DoesNotExist (resource_designer_cs); + + Assert.IsTrue (builder.Build (proj), "build should succeed"); + + resource_designer_cs = Path.Combine (intermediate, "Resource.designer.cs"); + if (useDesignerAssembly) + resource_designer_cs = Path.Combine (intermediate, "__Microsoft.Android.Resource.Designer.cs"); + FileAssert.DoesNotExist (resource_designer_cs); + + var assemblyPath = Path.Combine (Root, builder.ProjectDirectory, proj.OutputPath, $"{proj.ProjectName}.dll"); + FileAssert.Exists (assemblyPath); + using var assembly = AssemblyDefinition.ReadAssembly (assemblyPath); + var typeName = $"{proj.ProjectName}.Resource"; + var type = assembly.MainModule.GetType (typeName); + Assert.IsNull (type, $"{assemblyPath} should *not* contain {typeName}"); + } + [Test] public void CheckThatXA1034IsRaisedForInvalidConfiguration ([Values (true, false)] bool isRelease) { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AotTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AotTests.cs index 37f0fcfcf8b..db5da19d657 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AotTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AotTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; @@ -8,6 +9,7 @@ using NUnit.Framework; using Xamarin.ProjectTools; using Xamarin.Android.Build; +using Xamarin.Android.Tasks; namespace Xamarin.Android.Build.Tests { @@ -486,5 +488,45 @@ public void AotAssembliesInIDE () Assert.IsNotNull (entry, $"{path} should be in {apk}", abi); } } + + [Test] + public void CheckWhetherLibcAndLibmAreReferencedInAOTLibraries () + { + if (IsWindows) + Assert.Ignore ("https://github.com/dotnet/runtime/issues/88625"); + + var proj = new XamarinAndroidApplicationProject { + IsRelease = true, + EmbedAssembliesIntoApk = true, + AotAssemblies = true, + }; + proj.SetProperty ("EnableLLVM", "True"); + + var abis = new [] { "arm64-v8a", "x86_64" }; + proj.SetAndroidSupportedAbis (abis); + + var libPaths = new List (); + if (Builder.UseDotNet) { + libPaths.Add (Path.Combine ("android-arm64", "aot", "Mono.Android.dll.so")); + libPaths.Add (Path.Combine ("android-x64", "aot", "Mono.Android.dll.so")); + } else { + libPaths.Add (Path.Combine ("aot", "arm64-v8a", "libaot-Mono.Android.dll.so")); + libPaths.Add (Path.Combine ("aot", "x86_64", "libaot-Mono.Android.dll.so")); + } + + using (var b = CreateApkBuilder ()) { + Assert.IsTrue (b.Build (proj), "Build should have succeeded."); + string objPath = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath); + + foreach (string libPath in libPaths) { + string lib = Path.Combine (objPath, libPath); + + Assert.IsTrue (File.Exists (lib), $"Library {lib} should exist on disk"); + Assert.IsTrue (ELFHelper.ReferencesLibrary (lib, "libc.so"), $"Library {lib} should reference libc.so"); + Assert.IsTrue (ELFHelper.ReferencesLibrary (lib, "libm.so"), $"Library {lib} should reference libm.so"); + } + } + } + } } diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BindingBuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BindingBuildTest.cs index 99142a257c8..70e42e8c71f 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BindingBuildTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BindingBuildTest.cs @@ -12,8 +12,53 @@ namespace Xamarin.Android.Build.Tests { [Parallelizable (ParallelScope.Children)] - public class BindingBuildTest : BaseTest { -#pragma warning disable 414 + public class BindingBuildTest : BaseTest + { + [Test] + public void DotNetBuildBinding () + { + var proj = new XamarinAndroidLibraryProject () { + EnableDefaultItems = true, + }; + // Both transform files should be applied + proj.Sources.Add (new AndroidItem.TransformFile ("Transforms.xml") { + TextContent = () => +@" + FooBar +", + }); + proj.Sources.Add (new AndroidItem.TransformFile ("Transforms\\Metadata.xml") { + TextContent = () => +@" + MSBuildTest +", + }); + proj.Sources.Add (new AndroidItem.AndroidLibrary ("javaclasses.jar") { + BinaryContent = () => ResourceData.JavaSourceJarTestJar, + }); + proj.OtherBuildItems.Add (new BuildItem ("JavaSourceJar", "javaclasses-sources.jar") { + BinaryContent = () => ResourceData.JavaSourceJarTestSourcesJar, + }); + proj.OtherBuildItems.Add (new AndroidItem.AndroidJavaSource ("JavaSourceTestExtension.java") { + Encoding = Encoding.ASCII, + TextContent = () => ResourceData.JavaSourceTestExtension, + Metadata = { { "Bind", "True"} }, + }); + var builder = CreateDllBuilder (); + Assert.IsTrue (builder.Build (proj), "`dotnet build` should succeed"); + + var assemblyPath = Path.Combine (Root, builder.ProjectDirectory, proj.OutputPath, "UnnamedProject.dll"); + FileAssert.Exists (assemblyPath); + using (var assembly = AssemblyDefinition.ReadAssembly (assemblyPath)) { + var typeName = "MSBuildTest.JavaSourceJarTest"; + var type = assembly.MainModule.GetType (typeName); + Assert.IsNotNull (type, $"{assemblyPath} should contain {typeName}"); + typeName = "MSBuildTest.JavaSourceTestExtension"; + type = assembly.MainModule.GetType (typeName); + Assert.IsNotNull (type, $"{assemblyPath} should contain {typeName}"); + } + } + static object [] ClassParseOptions = new object [] { new object[] { /* classParser */ "class-parse", @@ -22,7 +67,7 @@ public class BindingBuildTest : BaseTest { [Test] [TestCaseSource (nameof (ClassParseOptions))] - public void BuildBasicBindingLibrary (string classParser) + public void BindingLibraryIncremental (string classParser) { var targets = new List { "_ExportJarToXml", @@ -475,6 +520,39 @@ public void JavaSourceJar () } } + [Test] + public void AppWithSingleJar () + { + var proj = new XamarinAndroidApplicationProject { + EnableDefaultItems = true, + Sources = { + new AndroidItem.AndroidLibrary ("Jars\\javaclasses.jar") { + BinaryContent = () => ResourceData.JavaSourceJarTestJar, + } + } + }; + + var builder = CreateApkBuilder (); + Assert.IsTrue (builder.Build (proj), "first build should succeed"); + + var assemblyPath = Path.Combine (Root, builder.ProjectDirectory, proj.OutputPath, $"{proj.ProjectName}.dll"); + var typeName = "Com.Xamarin.Android.Test.Msbuildtest.JavaSourceJarTest"; + FileAssert.Exists (assemblyPath); + using (var assembly = AssemblyDefinition.ReadAssembly (assemblyPath)) { + Assert.IsNotNull (assembly.MainModule.GetType (typeName), $"{assemblyPath} should contain {typeName}"); + } + + // Remove the @(AndroidLibrary) & build again + proj.Sources.RemoveAt (proj.Sources.Count - 1); + Directory.Delete (Path.Combine (Root, builder.ProjectDirectory, "Jars"), recursive: true); + Assert.IsTrue (builder.Build (proj), "second build should succeed"); + + FileAssert.Exists (assemblyPath); + using (var assembly = AssemblyDefinition.ReadAssembly (assemblyPath)) { + Assert.IsNull (assembly.MainModule.GetType (typeName), $"{assemblyPath} should *not* contain {typeName}"); + } + } + [Test] [TestCaseSource (nameof (ClassParseOptions))] public void DesignTimeBuild (string classParser) diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.TestCaseSource.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.TestCaseSource.cs index f0f22e2ef53..29a390c9835 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.TestCaseSource.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.TestCaseSource.cs @@ -11,6 +11,105 @@ namespace Xamarin.Android.Build.Tests { public partial class BuildTest : BaseTest { + static readonly object [] DotNetBuildSource = new object [] { + new object [] { + /* runtimeIdentifiers */ "android-arm", + /* isRelease */ false, + /* aot */ false, + /* usesAssemblyStore */ false, + }, + new object [] { + /* runtimeIdentifiers */ "android-arm", + /* isRelease */ false, + /* aot */ false, + /* usesAssemblyStore */ true, + }, + new object [] { + /* runtimeIdentifiers */ "android-arm64", + /* isRelease */ false, + /* aot */ false, + /* usesAssemblyStore */ false, + }, + new object [] { + /* runtimeIdentifiers */ "android-x86", + /* isRelease */ false, + /* aot */ false, + /* usesAssemblyStore */ false, + }, + new object [] { + /* runtimeIdentifiers */ "android-x64", + /* isRelease */ false, + /* aot */ false, + /* usesAssemblyStore */ false, + }, + new object [] { + /* runtimeIdentifiers */ "android-arm", + /* isRelease */ true, + /* aot */ false, + /* usesAssemblyStore */ false, + }, + new object [] { + /* runtimeIdentifiers */ "android-arm", + /* isRelease */ true, + /* aot */ false, + /* usesAssemblyStore */ true, + }, + new object [] { + /* runtimeIdentifiers */ "android-arm", + /* isRelease */ true, + /* aot */ true, + /* usesAssemblyStore */ false, + }, + new object [] { + /* runtimeIdentifiers */ "android-arm", + /* isRelease */ true, + /* aot */ true, + /* usesAssemblyStore */ true, + }, + new object [] { + /* runtimeIdentifiers */ "android-arm64", + /* isRelease */ true, + /* aot */ false, + /* usesAssemblyStore */ false, + }, + new object [] { + /* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64", + /* isRelease */ false, + /* aot */ false, + /* usesAssemblyStore */ false, + }, + new object [] { + /* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64", + /* isRelease */ false, + /* aot */ false, + /* usesAssemblyStore */ true, + }, + new object [] { + /* runtimeIdentifiers */ "android-arm;android-arm64;android-x86", + /* isRelease */ true, + /* aot */ false, + /* usesAssemblyStore */ false, + }, + new object [] { + /* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64", + /* isRelease */ true, + /* aot */ false, + /* usesAssemblyStore */ false, + }, + new object [] { + /* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64", + /* isRelease */ true, + /* aot */ false, + /* usesAssemblyStore */ true, + }, + new object [] { + /* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64", + /* isRelease */ true, + /* aot */ true, + /* usesAssemblyStore */ false, + }, + }; + #pragma warning disable 414 static object [] RuntimeChecks () => new object [] { new object[] { 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 149caaf74be..1ea69378427 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 @@ -22,6 +22,146 @@ namespace Xamarin.Android.Build.Tests [Parallelizable (ParallelScope.Children)] public partial class BuildTest : BaseTest { + [Test] + [Category ("SmokeTests")] + [TestCaseSource (nameof (DotNetBuildSource))] + [NonParallelizable] // On MacOS, parallel /restore causes issues + public void DotNetBuild (string runtimeIdentifiers, bool isRelease, bool aot, bool usesAssemblyStore) + { + var proj = new XamarinAndroidApplicationProject { + IsRelease = isRelease, + EnableDefaultItems = true, + ExtraNuGetConfigSources = { + // Microsoft.AspNetCore.Components.WebView is not in dotnet-public + "https://api.nuget.org/v3/index.json", + }, + PackageReferences = { + new Package { Id = "Xamarin.AndroidX.AppCompat", Version = "1.3.1.1" }, + // Using * here, so we explicitly get newer packages + new Package { Id = "Microsoft.AspNetCore.Components.WebView", Version = "6.0.0-*" }, + new Package { Id = "Microsoft.Extensions.FileProviders.Embedded", Version = "6.0.0-*" }, + new Package { Id = "Microsoft.JSInterop", Version = "6.0.0-*" }, + new Package { Id = "System.Text.Json", Version = "6.0.0-*" }, + }, + Sources = { + new BuildItem ("EmbeddedResource", "Foo.resx") { + TextContent = () => InlineData.ResxWithContents ("Cancel") + }, + new BuildItem ("EmbeddedResource", "Foo.es.resx") { + TextContent = () => InlineData.ResxWithContents ("Cancelar") + }, + new AndroidItem.TransformFile ("Transforms.xml") { + // Remove two methods that introduced warnings: + // Com.Balysv.Material.Drawable.Menu.MaterialMenuView.cs(214,30): warning CS0114: 'MaterialMenuView.OnRestoreInstanceState(IParcelable)' hides inherited member 'View.OnRestoreInstanceState(IParcelable?)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword. + // Com.Balysv.Material.Drawable.Menu.MaterialMenuView.cs(244,56): warning CS0114: 'MaterialMenuView.OnSaveInstanceState()' hides inherited member 'View.OnSaveInstanceState()'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword. + TextContent = () => "", + }, + new AndroidItem.AndroidLibrary ("material-menu-1.1.0.aar") { + WebContent = "https://repo1.maven.org/maven2/com/balysv/material-menu/1.1.0/material-menu-1.1.0.aar" + }, + } + }; + proj.MainActivity = proj.DefaultMainActivity.Replace (": Activity", ": AndroidX.AppCompat.App.AppCompatActivity"); + proj.SetProperty ("AndroidUseAssemblyStore", usesAssemblyStore.ToString ()); + proj.SetProperty ("RunAOTCompilation", aot.ToString ()); + proj.OtherBuildItems.Add (new AndroidItem.InputJar ("javaclasses.jar") { + BinaryContent = () => ResourceData.JavaSourceJarTestJar, + }); + proj.OtherBuildItems.Add (new BuildItem ("JavaSourceJar", "javaclasses-sources.jar") { + BinaryContent = () => ResourceData.JavaSourceJarTestSourcesJar, + }); + proj.OtherBuildItems.Add (new AndroidItem.AndroidJavaSource ("JavaSourceTestExtension.java") { + Encoding = Encoding.ASCII, + TextContent = () => ResourceData.JavaSourceTestExtension, + Metadata = { { "Bind", "True"} }, + }); + if (!runtimeIdentifiers.Contains (";")) { + proj.SetProperty (KnownProperties.RuntimeIdentifier, runtimeIdentifiers); + } else { + proj.SetProperty (KnownProperties.RuntimeIdentifiers, runtimeIdentifiers); + } + + var builder = CreateApkBuilder (); + Assert.IsTrue (builder.Build (proj), "`dotnet build` should succeed"); + builder.AssertHasNoWarnings (); + + var outputPath = Path.Combine (Root, builder.ProjectDirectory, proj.OutputPath); + var intermediateOutputPath = Path.Combine (Root, builder.ProjectDirectory, proj.IntermediateOutputPath); + if (!runtimeIdentifiers.Contains (";")) { + outputPath = Path.Combine (outputPath, runtimeIdentifiers); + intermediateOutputPath = Path.Combine (intermediateOutputPath, runtimeIdentifiers); + } + + var files = Directory.EnumerateFileSystemEntries (outputPath) + .Select (Path.GetFileName) + .OrderBy (f => f, StringComparer.OrdinalIgnoreCase) + .ToArray (); + var expectedFiles = new List { + $"{proj.PackageName}-Signed.apk", + "es", + $"{proj.ProjectName}.dll", + $"{proj.ProjectName}.pdb", + $"{proj.ProjectName}.runtimeconfig.json", + $"{proj.ProjectName}.xml", + }; + if (isRelease) { + expectedFiles.Add ($"{proj.PackageName}.aab"); + expectedFiles.Add ($"{proj.PackageName}-Signed.aab"); + } else { + expectedFiles.Add ($"{proj.PackageName}.apk"); + expectedFiles.Add ($"{proj.PackageName}-Signed.apk.idsig"); + } + + expectedFiles.Sort(StringComparer.OrdinalIgnoreCase); + + CollectionAssert.AreEquivalent (expectedFiles, files, $"Expected: {string.Join (";", expectedFiles)}\n Found: {string.Join (";", files)}"); + + var assemblyPath = Path.Combine (outputPath, $"{proj.ProjectName}.dll"); + FileAssert.Exists (assemblyPath); + using (var assembly = AssemblyDefinition.ReadAssembly (assemblyPath)) { + var typeName = "Com.Xamarin.Android.Test.Msbuildtest.JavaSourceJarTest"; + Assert.IsNotNull (assembly.MainModule.GetType (typeName), $"{assemblyPath} should contain {typeName}"); + typeName = "Com.Balysv.Material.Drawable.Menu.MaterialMenuView"; + Assert.IsNotNull (assembly.MainModule.GetType (typeName), $"{assemblyPath} should contain {typeName}"); + typeName = "Com.Xamarin.Android.Test.Msbuildtest.JavaSourceTestExtension"; + Assert.IsNotNull (assembly.MainModule.GetType (typeName), $"{assemblyPath} should contain {typeName}"); + } + + var rids = runtimeIdentifiers.Split (';'); + + // Check AndroidManifest.xml + var manifestPath = Path.Combine (intermediateOutputPath, "android", "AndroidManifest.xml"); + FileAssert.Exists (manifestPath); + var manifest = XDocument.Load (manifestPath); + XNamespace ns = "http://schemas.android.com/apk/res/android"; + var uses_sdk = manifest.Root.Element ("uses-sdk"); + Assert.AreEqual ("21", uses_sdk.Attribute (ns + "minSdkVersion").Value); + Assert.AreEqual (XABuildConfig.AndroidDefaultTargetDotnetApiLevel.ToString(), + uses_sdk.Attribute (ns + "targetSdkVersion").Value); + + bool expectEmbeddedAssembies = !(CommercialBuildAvailable && !isRelease); + var apkPath = Path.Combine (outputPath, $"{proj.PackageName}-Signed.apk"); + FileAssert.Exists (apkPath); + var helper = new ArchiveAssemblyHelper (apkPath, usesAssemblyStore, rids); + helper.AssertContainsEntry ($"assemblies/{proj.ProjectName}.dll", shouldContainEntry: expectEmbeddedAssembies); + helper.AssertContainsEntry ($"assemblies/{proj.ProjectName}.pdb", shouldContainEntry: !CommercialBuildAvailable && !isRelease); + helper.AssertContainsEntry ($"assemblies/Mono.Android.dll", shouldContainEntry: expectEmbeddedAssembies); + helper.AssertContainsEntry ($"assemblies/es/{proj.ProjectName}.resources.dll", shouldContainEntry: expectEmbeddedAssembies); + foreach (var abi in rids.Select (AndroidRidAbiHelper.RuntimeIdentifierToAbi)) { + helper.AssertContainsEntry ($"lib/{abi}/libmonodroid.so"); + helper.AssertContainsEntry ($"lib/{abi}/libmonosgen-2.0.so"); + if (rids.Length > 1) { + helper.AssertContainsEntry ($"assemblies/{abi}/System.Private.CoreLib.dll", shouldContainEntry: expectEmbeddedAssembies); + } else { + helper.AssertContainsEntry ("assemblies/System.Private.CoreLib.dll", shouldContainEntry: expectEmbeddedAssembies); + } + if (aot) { + helper.AssertContainsEntry ($"lib/{abi}/libaot-{proj.ProjectName}.dll.so"); + helper.AssertContainsEntry ($"lib/{abi}/libaot-Mono.Android.dll.so"); + } + } + } + static object [] MonoComponentMaskChecks () => new object [] { new object[] { true, // enableProfiler @@ -61,18 +201,19 @@ public void CheckMonoComponentsMask (bool enableProfiler, bool useInterpreter, b return; } - var proj = new XamarinAndroidApplicationProject () { + var proj = new XamarinFormsAndroidApplicationProject () { IsRelease = !debugBuild, }; proj.SetProperty (proj.ActiveConfigurationProperties, "AndroidEnableProfiler", enableProfiler.ToString ()); - proj.SetProperty (proj.ActiveConfigurationProperties, "AndroidUseInterpreter", useInterpreter.ToString ()); + proj.SetProperty (proj.ActiveConfigurationProperties, "UseInterpreter", useInterpreter.ToString ()); var abis = new [] { "armeabi-v7a", "x86" }; proj.SetAndroidSupportedAbis (abis); using (var b = CreateApkBuilder ()) { Assert.IsTrue (b.Build (proj), "Build should have succeeded."); + b.AssertHasNoWarnings (); string objPath = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath); List envFiles = EnvironmentHelper.GatherEnvironmentFiles (objPath, String.Join (";", abis), true); @@ -82,45 +223,6 @@ public void CheckMonoComponentsMask (bool enableProfiler, bool useInterpreter, b } } - [Test] - public void CheckWhetherLibcAndLibmAreReferencedInAOTLibraries () - { - if (IsWindows) - Assert.Ignore ("https://github.com/dotnet/runtime/issues/88625"); - - var proj = new XamarinAndroidApplicationProject { - IsRelease = true, - EmbedAssembliesIntoApk = true, - AotAssemblies = true, - }; - proj.SetProperty ("EnableLLVM", "True"); - - var abis = new [] { "arm64-v8a", "x86_64" }; - proj.SetAndroidSupportedAbis (abis); - - var libPaths = new List (); - if (Builder.UseDotNet) { - libPaths.Add (Path.Combine ("android-arm64", "aot", "Mono.Android.dll.so")); - libPaths.Add (Path.Combine ("android-x64", "aot", "Mono.Android.dll.so")); - } else { - libPaths.Add (Path.Combine ("aot", "arm64-v8a", "libaot-Mono.Android.dll.so")); - libPaths.Add (Path.Combine ("aot", "x86_64", "libaot-Mono.Android.dll.so")); - } - - using (var b = CreateApkBuilder ()) { - Assert.IsTrue (b.Build (proj), "Build should have succeeded."); - string objPath = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath); - - foreach (string libPath in libPaths) { - string lib = Path.Combine (objPath, libPath); - - Assert.IsTrue (File.Exists (lib), $"Library {lib} should exist on disk"); - Assert.IsTrue (ELFHelper.ReferencesLibrary (lib, "libc.so"), $"Library {lib} should reference libc.so"); - Assert.IsTrue (ELFHelper.ReferencesLibrary (lib, "libm.so"), $"Library {lib} should reference libm.so"); - } - } - } - static object [] CheckAssemblyCountsSource = new object [] { new object[] { /*isRelease*/ false, @@ -311,162 +413,6 @@ public void CheckSequencePointGeneration (bool isRelease, bool monoSymbolArchive } } - [Test] - [NonParallelizable] - public void BuildWithNativeLibraries ([Values (true, false)] bool isRelease) - { - var dll = new XamarinAndroidLibraryProject () { - ProjectName = "Library1", - IsRelease = isRelease, - OtherBuildItems = { - new AndroidItem.EmbeddedNativeLibrary ("foo\\armeabi-v7a\\libtest.so") { - BinaryContent = () => new byte[10], - MetadataValues = "Link=libs\\armeabi-v7a\\libtest.so", - }, - new AndroidItem.EmbeddedNativeLibrary ("foo\\x86\\libtest.so") { - BinaryContent = () => new byte[10], - MetadataValues = "Link=libs\\x86\\libtest.so", - }, - }, - }; - var dll2 = new XamarinAndroidLibraryProject () { - ProjectName = "Library2", - IsRelease = isRelease, - References = { - new BuildItem ("ProjectReference","..\\Library1\\Library1.csproj"), - }, - OtherBuildItems = { - new AndroidItem.EmbeddedNativeLibrary ("foo\\armeabi-v7a\\libtest1.so") { - BinaryContent = () => new byte[10], - MetadataValues = "Link=libs\\armeabi-v7a\\libtest1.so", - }, - new AndroidItem.EmbeddedNativeLibrary ("foo\\x86\\libtest1.so") { - BinaryContent = () => new byte[10], - MetadataValues = "Link=libs\\x86\\libtest1.so", - }, - }, - }; - var proj = new XamarinAndroidApplicationProject () { - IsRelease = isRelease, - References = { - new BuildItem ("ProjectReference","..\\Library1\\Library1.csproj"), - new BuildItem ("ProjectReference","..\\Library2\\Library2.csproj"), - }, - OtherBuildItems = { - new AndroidItem.AndroidNativeLibrary ("armeabi-v7a\\libRSSupport.so") { - BinaryContent = () => new byte[10], - }, - }, - PackageReferences = { - KnownPackages.Xamarin_Android_Support_v8_RenderScript_28_0_0_3, - } - }; - proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); - if (!Builder.UseDotNet) { - //NOTE: Mono.Data.Sqlite and Mono.Posix do not exist in .NET 5+ - proj.References.Add (new BuildItem.Reference ("Mono.Data.Sqlite")); - proj.References.Add (new BuildItem.Reference ("Mono.Posix")); - proj.MainActivity = proj.DefaultMainActivity.Replace ("int count = 1;", @"int count = 1; -Mono.Data.Sqlite.SqliteConnection connection = null; -Mono.Unix.UnixFileInfo fileInfo = null;"); - } - var path = Path.Combine (Root, "temp", string.Format ("BuildWithNativeLibraries_{0}", isRelease)); - using (var b1 = CreateDllBuilder (Path.Combine (path, dll2.ProjectName))) { - Assert.IsTrue (b1.Build (dll2), "Build should have succeeded."); - using (var b = CreateDllBuilder (Path.Combine (path, dll.ProjectName))) { - Assert.IsTrue (b.Build (dll), "Build should have succeeded."); - using (var builder = CreateApkBuilder (Path.Combine (path, proj.ProjectName))) { - Assert.IsTrue (builder.Build (proj), "Build should have succeeded."); - var apk = Path.Combine (Root, builder.ProjectDirectory, - proj.OutputPath, $"{proj.PackageName}-Signed.apk"); - FileAssert.Exists (apk); - Assert.IsTrue (StringAssertEx.ContainsText (builder.LastBuildOutput, "warning XA4301: APK already contains the item lib/armeabi-v7a/libRSSupport.so; ignoring."), - "warning about skipping libRSSupport.so should have been raised"); - using (var zipFile = ZipHelper.OpenZip (apk)) { - var data = ZipHelper.ReadFileFromZip (zipFile, "lib/x86/libtest.so"); - Assert.IsNotNull (data, "libtest.so for x86 should exist in the apk."); - data = ZipHelper.ReadFileFromZip (zipFile, "lib/armeabi-v7a/libtest.so"); - Assert.IsNotNull (data, "libtest.so for armeabi-v7a should exist in the apk."); - data = ZipHelper.ReadFileFromZip (zipFile, "lib/x86/libtest1.so"); - Assert.IsNotNull (data, "libtest1.so for x86 should exist in the apk."); - data = ZipHelper.ReadFileFromZip (zipFile, "lib/armeabi-v7a/libtest1.so"); - Assert.IsNotNull (data, "libtest1.so for armeabi-v7a should exist in the apk."); - data = ZipHelper.ReadFileFromZip (zipFile, "lib/armeabi-v7a/libRSSupport.so"); - Assert.IsNotNull (data, "libRSSupport.so for armeabi-v7a should exist in the apk."); - if (Builder.UseDotNet) { - data = ZipHelper.ReadFileFromZip (zipFile, "lib/x86/libSystem.Native.so"); - Assert.IsNotNull (data, "libSystem.Native.so for x86 should exist in the apk."); - data = ZipHelper.ReadFileFromZip (zipFile, "lib/armeabi-v7a/libSystem.Native.so"); - Assert.IsNotNull (data, "libSystem.Native.so for armeabi-v7a should exist in the apk."); - } else { - data = ZipHelper.ReadFileFromZip (zipFile, "lib/x86/libmono-native.so"); - Assert.IsNotNull (data, "libmono-native.so for x86 should exist in the apk."); - data = ZipHelper.ReadFileFromZip (zipFile, "lib/armeabi-v7a/libmono-native.so"); - Assert.IsNotNull (data, "libmono-native.so for armeabi-v7a should exist in the apk."); - data = ZipHelper.ReadFileFromZip (zipFile, "lib/x86/libMonoPosixHelper.so"); - Assert.IsNotNull (data, "libMonoPosixHelper.so for x86 should exist in the apk."); - data = ZipHelper.ReadFileFromZip (zipFile, "lib/armeabi-v7a/libMonoPosixHelper.so"); - Assert.IsNotNull (data, "libMonoPosixHelper.so for armeabi-v7a should exist in the apk."); - data = ZipHelper.ReadFileFromZip (zipFile, "lib/x86/libsqlite3_xamarin.so"); - Assert.IsNotNull (data, "libsqlite3_xamarin.so for x86 should exist in the apk."); - data = ZipHelper.ReadFileFromZip (zipFile, "lib/armeabi-v7a/libsqlite3_xamarin.so"); - Assert.IsNotNull (data, "libsqlite3_xamarin.so for armeabi-v7a should exist in the apk."); - } - } - } - } - } - Directory.Delete (path, recursive: true); - } - - [Test] - public void BuildWithNativeLibraryUnknownAbi () - { - var proj = new XamarinAndroidApplicationProject () { - OtherBuildItems = { - new AndroidItem.AndroidNativeLibrary ("not-a-real-abi\\libtest.so") { - BinaryContent = () => new byte[10], - }, - } - }; - proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); - - using (var builder = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) { - builder.ThrowOnBuildFailure = false; - Assert.IsFalse (builder.Build (proj), "Build should have failed."); - Assert.IsTrue (StringAssertEx.ContainsText (builder.LastBuildOutput, $"error XA4301: Cannot determine ABI of native library 'not-a-real-abi{Path.DirectorySeparatorChar}libtest.so'. Move this file to a directory with a valid Android ABI name such as 'libs/armeabi-v7a/'."), - "error about libtest.so should have been raised"); - } - } - - [Test] - public void BuildWithExternalJavaLibrary () - { - var path = Path.Combine ("temp", TestName); - var binding = new XamarinAndroidBindingProject { - ProjectName = "BuildWithExternalJavaLibraryBinding", - AndroidClassParser = "class-parse", - }; - using (var bbuilder = CreateDllBuilder (Path.Combine (path, "BuildWithExternalJavaLibraryBinding"))) { - string multidex_jar = Path.Combine (TestEnvironment.AndroidMSBuildDirectory, "android-support-multidex.jar"); - binding.Jars.Add (new AndroidItem.InputJar (() => multidex_jar)); - - Assert.IsTrue (bbuilder.Build (binding), "Binding build should succeed."); - var proj = new XamarinAndroidApplicationProject { - References = { new BuildItem ("ProjectReference", "..\\BuildWithExternalJavaLibraryBinding\\BuildWithExternalJavaLibraryBinding.csproj"), }, - OtherBuildItems = { new BuildItem ("AndroidExternalJavaLibrary", multidex_jar) }, - Sources = { - new BuildItem ("Compile", "Foo.cs") { - TextContent = () => "public class Foo { public void X () { new Android.Support.Multidex.MultiDexApplication (); } }" - } - }, - }; - using (var builder = CreateApkBuilder (Path.Combine (path, "BuildWithExternalJavaLibrary"))) { - Assert.IsTrue (builder.Build (proj), "App build should succeed"); - } - } - } - [Test] public void CheckItemMetadata ([Values (true, false)] bool isRelease) { @@ -841,52 +787,6 @@ public void BuildApplicationWithSpacesInPath ([Values (true, false)] bool enable } } - [Test] - public void BuildReleaseApplicationWithNugetPackages () - { - var proj = new XamarinAndroidApplicationProject () { - IsRelease = true, - PackageReferences = { - KnownPackages.AndroidSupportV4_27_0_2_1, - }, - }; - using (var b = CreateApkBuilder ()) { - Assert.IsTrue (b.Build (proj), "Build should have succeeded."); - var assets = b.Output.GetIntermediaryAsText (Path.Combine ("..", "project.assets.json")); - StringAssert.Contains ("Xamarin.Android.Support.v4", assets, - "Nuget Package Xamarin.Android.Support.v4.21.0.3.0 should have been restored."); - var src = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "android", "src"); - var main_r_java = Path.Combine (src, proj.PackageNameJavaIntermediatePath, "R.java"); - FileAssert.Exists (main_r_java); - var lib_r_java = Path.Combine (src, "android", "support", "compat", "R.java"); - FileAssert.Exists (lib_r_java); - } - } - - [Test] - public void BuildAfterAddingNuget () - { - var proj = new XamarinAndroidApplicationProject () { - IsRelease = true, - TargetFrameworkVersion = "7.1", - }; - using (var b = CreateApkBuilder ()) { - Assert.IsTrue (b.Build (proj), "first build should have succeeded."); - string build_props = b.Output.GetIntermediaryPath ("build.props"); - FileAssert.Exists (build_props, "build.props should exist after first build."); - proj.PackageReferences.Add (KnownPackages.SupportV7CardView_27_0_2_1); - - Assert.IsTrue (b.Build (proj, doNotCleanupOnUpdate: true), "second build should have succeeded."); - FileAssert.Exists (build_props, "build.props should exist after second build."); - - proj.MainActivity = proj.DefaultMainActivity.Replace ("clicks", "CLICKS"); - proj.Touch ("MainActivity.cs"); - Assert.IsTrue (b.Build (proj, doNotCleanupOnUpdate: true), "third build should have succeeded."); - Assert.IsTrue (b.Output.IsTargetSkipped ("_CleanIntermediateIfNeeded"), "A build with no changes to NuGets should *not* trigger `_CleanIntermediateIfNeeded`!"); - FileAssert.Exists (build_props, "build.props should exist after third build."); - } - } - //This test validates the _CleanIntermediateIfNeeded target [Test] [NonParallelizable] @@ -958,151 +858,6 @@ public void BuildInDesignTimeMode ([Values(false, true)] bool useManagedParser) } } - [Test] - public void AndroidLibraryProjectsZipWithOddPaths () - { - var proj = new XamarinAndroidLibraryProject (); - proj.Imports.Add (new Import ("foo.props") { - TextContent = () => $@" - - - $(MSBuildThisFileDirectory)../{TestContext.CurrentContext.Test.Name}/obj/$(Configuration)/foo/ - - " - }); - proj.AndroidResources.Add (new AndroidItem.AndroidResource ("Resources\\values\\foo.xml") { - TextContent = () => @"bar", - }); - using (var b = CreateDllBuilder ()) { - Assert.IsTrue (b.Build (proj), "Build should have succeeded."); - - var zipFile = Path.Combine (Root, b.ProjectDirectory, b.Output.OutputPath, $"{proj.ProjectName}.aar"); - FileAssert.Exists (zipFile); - using (var zip = ZipHelper.OpenZip (zipFile)) { - Assert.IsTrue (zip.ContainsEntry ("res/values/foo.xml"), $"{zipFile} should contain a res/values/foo.xml entry"); - } - } - } - -#pragma warning disable 414 - static object [] validateJavaVersionTestCases = new object [] { - new object [] { - /*targetFrameworkVersion*/ "v7.1", - /*buildToolsVersion*/ "24.0.1", - /*JavaVersion*/ "1.8.0_101", - /*latestSupportedJavaVersion*/ "1.8.0", - /*expectedResult*/ true, - }, - new object [] { - /*targetFrameworkVersion*/ "v7.1", - /*buildToolsVersion*/ "24.0.1", - /*JavaVersion*/ "1.7.0_101", - /*latestSupportedJavaVersion*/ "1.8.0", - /*expectedResult*/ true, - }, - new object [] { - /*targetFrameworkVersion*/ "v7.1", - /*buildToolsVersion*/ "24.0.1", - /*JavaVersion*/ "1.6.0_101", - /*latestSupportedJavaVersion*/ "1.8.0", - /*expectedResult*/ true, - }, - new object [] { - /*targetFrameworkVersion*/ "v6.0", - /*buildToolsVersion*/ "24.0.1", - /*JavaVersion*/ "1.8.0_101", - /*latestSupportedJavaVersion*/ "1.8.0", - /*expectedResult*/ true, - }, - new object [] { - /*targetFrameworkVersion*/ "v6.0", - /*buildToolsVersion*/ "24.0.0", - /*JavaVersion*/ "1.7.0_101", - /*latestSupportedJavaVersion*/ "1.8.0", - /*expectedResult*/ true, - }, - new object [] { - /*targetFrameworkVersion*/ "v6.0", - /*buildToolsVersion*/ "24.0.0", - /*JavaVersion*/ "1.6.0_101", - /*latestSupportedJavaVersion*/ "1.8.0", - /*expectedResult*/ true, - }, - new object [] { - /*targetFrameworkVersion*/ "v5.0", - /*buildToolsVersion*/ "24.0.1", - /*JavaVersion*/ "1.8.0_101", - /*latestSupportedJavaVersion*/ "1.8.0", - /*expectedResult*/ true, - }, - new object [] { - /*targetFrameworkVersion*/ "v5.0", - /*buildToolsVersion*/ "24.0.0", - /*JavaVersion*/ "1.7.0_101", - /*latestSupportedJavaVersion*/ "1.8.0", - /*expectedResult*/ true, - }, - new object [] { - /*targetFrameworkVersion*/ "v5.0", - /*buildToolsVersion*/ "24.0.0", - /*JavaVersion*/ "1.6.0_101", - /*latestSupportedJavaVersion*/ "1.8.0", - /*expectedResult*/ true, - }, - new object [] { - /*targetFrameworkVersion*/ "v5.0", - /*buildToolsVersion*/ "24.0.1", - /*JavaVersion*/ "1.6.0_101", - /*latestSupportedJavaVersion*/ "1.8.0", - /*expectedResult*/ true, - }, - new object [] { - /*targetFrameworkVersion*/ "v7.1", - /*buildToolsVersion*/ "24.0.1", - /*JavaVersion*/ "1.6.x_101", - /*latestSupportedJavaVersion*/ "1.8.0", - /*expectedResult*/ true, - }, - new object [] { - /*targetFrameworkVersion*/ "v8.1", - /*buildToolsVersion*/ "24.0.1", - /*JavaVersion*/ "9.0.4", - /*latestSupportedJavaVersion*/ "1.8.0", - /*expectedResult*/ true, - }, - }; -#pragma warning restore 414 - - [Test] - [TestCaseSource (nameof (validateJavaVersionTestCases))] - public void ValidateJavaVersion (string targetFrameworkVersion, string buildToolsVersion, string javaVersion, string latestSupportedJavaVersion, bool expectedResult) - { - var path = Path.Combine ("temp", $"ValidateJavaVersion_{targetFrameworkVersion}_{buildToolsVersion}_{latestSupportedJavaVersion}_{javaVersion}"); - string javaExe = "java"; - string javacExe; - var javaPath = CreateFauxJavaSdkDirectory (Path.Combine (path, "JavaSDK"), javaVersion, out javaExe, out javacExe); - var AndroidSdkDirectory = CreateFauxAndroidSdkDirectory (Path.Combine (path, "android-sdk"), buildToolsVersion); - var proj = new XamarinAndroidApplicationProject () { - IsRelease = true, - TargetFrameworkVersion = targetFrameworkVersion, - UseLatestPlatformSdk = false, - }; - using (var builder = CreateApkBuilder (Path.Combine (path, proj.ProjectName), false, false)) { - builder.ThrowOnBuildFailure = false; - builder.Target = "_ResolveSdks"; - Assert.AreEqual (expectedResult, builder.Build (proj, parameters: new string[] { - $"JavaSdkDirectory={javaPath}", - $"JavaToolExe={javaExe}", - $"JavacToolExe={javacExe}", - $"AndroidSdkBuildToolsVersion={buildToolsVersion}", - $"AndroidSdkDirectory={AndroidSdkDirectory}", - $"LatestSupportedJavaVersion={latestSupportedJavaVersion}", - }), string.Format ("Build should have {0}", expectedResult ? "succeeded" : "failed")); - } - Directory.Delete (javaPath, recursive: true); - Directory.Delete (AndroidSdkDirectory, recursive: true); - } - [Test] public void IfAndroidJarDoesNotExistThrowXA5207 () { @@ -1330,47 +1085,6 @@ public void MicrosoftExtensionsHttp () } } - [Test] - public void XA0119 () - { - var proj = new XamarinAndroidApplicationProject (); - proj.SetProperty ("_XASupportsFastDev", "True"); - proj.SetProperty (proj.DebugProperties, "AndroidLinkMode", "Full"); - using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) { - b.Target = "Build"; // SignAndroidPackage would fail for OSS builds - Assert.IsTrue (b.Build (proj), "Build should have succeeded."); - Assert.IsTrue (StringAssertEx.ContainsText (b.LastBuildOutput, "XA0119"), "Output should contain XA0119 warnings"); - } - } - - [Test] - public void XA0119AAB () - { - var proj = new XamarinAndroidApplicationProject (); - proj.SetProperty ("_XASupportsFastDev", "True"); - proj.SetProperty ("AndroidPackageFormat", "aab"); - using (var builder = CreateApkBuilder ()) { - builder.ThrowOnBuildFailure = false; - Assert.IsTrue (builder.Build (proj), "Build should have succeeded."); - Assert.IsTrue (StringAssertEx.ContainsText (builder.LastBuildOutput, "XA0119"), "Output should contain XA0119 warnings"); - } - } - - [Test] - public void XA0119Interpreter () - { - var proj = new XamarinAndroidApplicationProject { - IsRelease = true, - AotAssemblies = true, - }; - proj.SetProperty ("UseInterpreter", "true"); - using (var builder = CreateApkBuilder ()) { - builder.ThrowOnBuildFailure = false; - Assert.IsTrue (builder.Build (proj), "Build should have succeeded."); - Assert.IsTrue (StringAssertEx.ContainsText (builder.LastBuildOutput, "XA0119"), "Output should contain XA0119 warnings"); - } - } - [Test] public void FastDeploymentDoesNotAddContentProvider () { @@ -1393,94 +1107,6 @@ public void FastDeploymentDoesNotAddContentProvider () } } - [Test] - public void DuplicateJCWNames () - { - var source = @"[Android.Runtime.Register (""examplelib.EmptyClass"")] public class EmptyClass : Java.Lang.Object { }"; - var library1 = new XamarinAndroidLibraryProject () { - ProjectName = "Library1", - Sources = { - new BuildItem.Source ("EmptyClass.cs") { - TextContent = () => source - } - } - }; - var library2 = new XamarinAndroidLibraryProject () { - ProjectName = "Library2", - Sources = { - new BuildItem.Source ("EmptyClass.cs") { - TextContent = () => source - } - } - }; - var app = new XamarinAndroidApplicationProject { - ProjectName = "App1", - References = { - new BuildItem ("ProjectReference", "..\\Library1\\Library1.csproj"), - new BuildItem ("ProjectReference", "..\\Library2\\Library2.csproj") - }, - }; - var projectPath = Path.Combine ("temp", TestName); - using (var lib1b = CreateDllBuilder (Path.Combine (projectPath, library1.ProjectName), cleanupAfterSuccessfulBuild: false)) - using (var lib2b = CreateDllBuilder (Path.Combine (projectPath, library2.ProjectName), cleanupAfterSuccessfulBuild: false)) { - Assert.IsTrue (lib1b.Build (library1), "Build of Library1 should have succeeded"); - Assert.IsTrue (lib2b.Build (library2), "Build of Library2 should have succeeded"); - using (var appb = CreateApkBuilder (Path.Combine (projectPath, app.ProjectName))) { - appb.ThrowOnBuildFailure = false; - Assert.IsFalse (appb.Build (app), "Build of App1 should have failed"); - IEnumerable errors = appb.LastBuildOutput.Where (x => x.Contains ("error XA4215")); - Assert.NotNull (errors, "Error should be XA4215"); - StringAssertEx.Contains ("EmptyClass", errors, "Error should mention the conflicting type name"); - StringAssertEx.Contains ("Library1", errors, "Error should mention all of the assemblies with conflicts"); - StringAssertEx.Contains ("Library2", errors, "Error should mention all of the assemblies with conflicts"); - } - } - } - - [Test] - public void DuplicateManagedNames () - { - var source = @"public class EmptyClass : Java.Lang.Object { }"; - var library1 = new XamarinAndroidLibraryProject () { - ProjectName = "Library1", - Sources = { - new BuildItem.Source ("EmptyClass.cs") { - TextContent = () => source - } - } - }; - var library2 = new XamarinAndroidLibraryProject () { - ProjectName = "Library2", - Sources = { - new BuildItem.Source ("EmptyClass.cs") { - TextContent = () => source - } - } - }; - var app = new XamarinAndroidApplicationProject { - ProjectName = "App1", - References = { - new BuildItem ("ProjectReference", "..\\Library1\\Library1.csproj"), - new BuildItem ("ProjectReference", "..\\Library2\\Library2.csproj") - }, - }; - var projectPath = Path.Combine ("temp", TestName); - using (var lib1b = CreateDllBuilder (Path.Combine (projectPath, library1.ProjectName), cleanupAfterSuccessfulBuild: false)) - using (var lib2b = CreateDllBuilder (Path.Combine (projectPath, library2.ProjectName), cleanupAfterSuccessfulBuild: false)) { - Assert.IsTrue (lib1b.Build (library1), "Build of Library1 should have succeeded"); - Assert.IsTrue (lib2b.Build (library2), "Build of Library2 should have succeeded"); - using (var appb = CreateApkBuilder (Path.Combine (projectPath, app.ProjectName))) { - appb.ThrowOnBuildFailure = false; - Assert.IsTrue (appb.Build (app), "Build of App1 should have succeeded"); - IEnumerable warnings = appb.LastBuildOutput.Where (x => x.Contains ("warning XA4214")); - Assert.NotNull (warnings, "Warning should be XA4214"); - StringAssertEx.Contains ("EmptyClass", warnings, "Warning should mention the conflicting type name"); - StringAssertEx.Contains ("Library1", warnings, "Warning should mention all of the assemblies with conflicts"); - StringAssertEx.Contains ("Library2", warnings, "Warning should mention all of the assemblies with conflicts"); - } - } - } - [Test] public void BuildOutsideVisualStudio () { @@ -1598,114 +1224,6 @@ public void AssemblyWithMissingTargetFramework () } } - [Test] - [Category ("Commercial")] - public void LibraryProjectsShouldSkipGetPrimaryCpuAbi () - { - if (!CommercialBuildAvailable) - Assert.Ignore ("Not required on Open Source Builds"); - const string target = "_GetPrimaryCpuAbi"; - var proj = new XamarinAndroidLibraryProject (); - using (var b = CreateDllBuilder (Path.Combine ("temp", TestName))) { - Assert.IsTrue (b.Build (proj), "Build should have succeeded."); - Assert.IsTrue (b.Output.IsTargetSkipped (target), $"`{target}` should be skipped!"); - } - } - - [Test] - [Category ("Commercial")] - public void LibraryReferenceWithHigherTFVShouldDisplayWarning ([Values (true, false)] bool isRelease) - { - if (!CommercialBuildAvailable || Builder.UseDotNet) - Assert.Ignore ("Not applicable to One .NET or single framework OSS builds."); - - var libproj = new XamarinAndroidLibraryProject () { - IsRelease = isRelease, - ProjectName = "Library1", - }; - var proj = new XamarinAndroidApplicationProject () { - IsRelease = isRelease, - ProjectName = "App1", - UseLatestPlatformSdk = false, - TargetFrameworkVersion = "v9.0", - References = { - new BuildItem ("ProjectReference", $"..\\{libproj.ProjectName}\\{Path.GetFileName (libproj.ProjectFilePath)}") - }, - }; - using (var libBuilder = CreateDllBuilder (Path.Combine ("temp", TestName, libproj.ProjectName))) - using (var appBuilder = CreateApkBuilder (Path.Combine ("temp", TestName, proj.ProjectName))) { - Assert.IsTrue (libBuilder.Build (libproj), "Library build should have succeeded."); - Assert.IsTrue (appBuilder.Build (proj), "App build should have succeeded."); - StringAssertEx.Contains ("warning XA0105", appBuilder.LastBuildOutput, "Build should have produced warning XA0105."); - } - } - - [Test] - public void AllResourcesInClassLibrary ([Values (true, false)] bool useAapt2, [Values (false, true)] bool useDesignerAssembly) - { - if (useDesignerAssembly && !Builder.UseDotNet) { - Assert.Ignore ($"Skipping, {useDesignerAssembly} not supported in Legacy."); - } - AssertAaptSupported (useAapt2); - var path = Path.Combine ("temp", TestName); - - // Create a "library" with all the application stuff in it - var lib = new XamarinAndroidApplicationProject { - ProjectName = "MyLibrary", - Sources = { - new BuildItem.Source ("Bar.cs") { - TextContent = () => "public class Bar { }" - }, - } - }; - lib.SetProperty ("AndroidApplication", "False"); - lib.SetProperty ("AndroidUseDesignerAssembly", useDesignerAssembly.ToString ()); - lib.AndroidUseAapt2 = useAapt2; - if (Builder.UseDotNet) { - lib.RemoveProperty ("OutputType"); - } - - // Create an "app" that is basically empty and references the library - var app = new XamarinAndroidLibraryProject { - ProjectName = "MyApp", - Sources = { - new BuildItem.Source ("Foo.cs") { - TextContent = () => "public class Foo : Bar { }" - }, - }, - OtherBuildItems = { - new BuildItem ("None", "Properties\\AndroidManifest.xml") { - TextContent = () => lib.AndroidManifest, - }, - } - }; - app.SetProperty ("AndroidUseDesignerAssembly", useDesignerAssembly.ToString ()); - app.AndroidResources.Clear (); // No Resources - if (Builder.UseDotNet) { - app.SetProperty (KnownProperties.OutputType, "Exe"); - } else { - app.SetProperty ("AndroidResgenFile", "Resources\\Resource.designer.cs"); - app.SetProperty ("AndroidApplication", "True"); - } - app.AndroidUseAapt2 = useAapt2; - - app.References.Add (new BuildItem.ProjectReference ($"..\\{lib.ProjectName}\\{lib.ProjectName}.csproj", lib.ProjectName, lib.ProjectGuid)); - - using (var libBuilder = CreateDllBuilder (Path.Combine (path, lib.ProjectName))) - using (var appBuilder = CreateApkBuilder (Path.Combine (path, app.ProjectName))) { - Assert.IsTrue (libBuilder.Build (lib), "library build should have succeeded."); - Assert.IsTrue (appBuilder.Build (app), "app build should have succeeded."); - - var r_txt = Path.Combine (Root, appBuilder.ProjectDirectory, app.IntermediateOutputPath, "R.txt"); - FileAssert.Exists (r_txt); - - var resource_designer_cs = GetResourceDesignerPath (appBuilder, app); - FileAssert.Exists (resource_designer_cs); - var contents = GetResourceDesignerText (app, resource_designer_cs); - Assert.AreNotEqual ("", contents); - } - } - [Test] public void WorkManager () { @@ -2094,138 +1612,6 @@ public void CheckLintConfigMerging () } } - [Test] - [NonParallelizable] // fails on NuGet restore - /// - /// Reference https://bugzilla.xamarin.com/show_bug.cgi?id=29568 - /// - public void BuildLibraryWhichUsesResources ([Values (false, true)] bool isRelease) - { - var proj = new XamarinAndroidLibraryProject { IsRelease = isRelease }; - proj.PackageReferences.Add (KnownPackages.AndroidXAppCompat); - proj.AndroidResources.Add (new AndroidItem.AndroidResource ("Resources\\values\\Styles.xml") { - TextContent = () => @" - -