Skip to content

Commit 805872b

Browse files
authored
[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.
1 parent 215ab4d commit 805872b

File tree

2 files changed

+165
-5
lines changed

2 files changed

+165
-5
lines changed

build-tools/automation/azure-pipelines.yaml

Lines changed: 133 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ resources:
3030
name: xamarin/release-scripts
3131
ref: refs/heads/sign-and-notarized
3232
endpoint: xamarin
33+
- repository: maui
34+
type: github
35+
name: dotnet/maui
36+
ref: refs/heads/net8.0
37+
endpoint: xamarin
3338

3439
parameters:
3540
- name: provisionatorChannel
@@ -277,13 +282,139 @@ stages:
277282
artifactName: Test Results - MSBuild Smoke - Linux
278283

279284
- template: yaml-templates/fail-on-issue.yaml
280-
285+
281286
- template: yaml-templates/stage-msbuild-tests.yaml
282-
287+
283288
- template: yaml-templates/stage-msbuild-emulator-tests.yaml
284289
parameters:
285290
usesCleanImages: ${{ parameters.macTestAgentsUseCleanImages }}
286291

292+
- stage: maui_tests
293+
displayName: MAUI Tests
294+
dependsOn: mac_build
295+
condition: eq(variables['System.PullRequest.TargetBranch'], 'main')
296+
jobs:
297+
# Check - "Xamarin.Android (MAUI Tests MAUI Integration)"
298+
- job: maui_tests_integration
299+
displayName: MAUI Integration
300+
pool: $(1ESWindowsPool)
301+
timeoutInMinutes: 180
302+
workspace:
303+
clean: all
304+
variables:
305+
BuildVersion: $(Build.BuildId)
306+
steps:
307+
- checkout: maui
308+
clean: true
309+
submodules: recursive
310+
path: s/maui
311+
persistCredentials: true
312+
313+
- template: yaml-templates/setup-test-environment.yaml
314+
parameters:
315+
xaSourcePath: $(Build.SourcesDirectory)/xamarin-android
316+
provisionClassic: false
317+
provisionatorChannel: ${{ parameters.provisionatorChannel }}
318+
installLegacyDotNet: false
319+
restoreNUnitConsole: false
320+
updateMono: false
321+
androidSdkPlatforms: 23,24,25,26,27,28,29,30,31,32,$(DefaultTestSdkPlatforms)
322+
323+
- task: NuGetAuthenticate@0
324+
displayName: authenticate with azure artifacts
325+
inputs:
326+
forceReinstallCredentialProvider: true
327+
328+
- script: |
329+
echo ##vso[task.setvariable variable=JI_JAVA_HOME]%JAVA_HOME_11_X64%
330+
echo ##vso[task.setvariable variable=JAVA_HOME]%JAVA_HOME_11_X64%
331+
displayName: set JI_JAVA_HOME, JAVA_HOME
332+
333+
- task: DownloadPipelineArtifact@2
334+
inputs:
335+
artifactName: $(NuGetArtifactName)
336+
downloadPath: $(Build.StagingDirectory)/android-packs
337+
338+
- pwsh: |
339+
$searchPath = Join-Path $(Build.StagingDirectory) android-packs
340+
$wlmanPack = Get-ChildItem $searchPath -Filter *Android*Manifest*.nupkg | Select-Object -First 1
341+
$dest = Join-Path $searchPath "tmp-wlman" "$($wlmanPack.BaseName)"
342+
Expand-Archive -LiteralPath $wlmanPack -DestinationPath $dest
343+
$wlmanJsonPath = Join-Path $dest "data" "WorkloadManifest.json"
344+
$json = Get-Content $wlmanJsonPath | ConvertFrom-Json -AsHashtable
345+
Write-Host "Setting variable ANDROID_PACK_VERSION = $($json["version"])"
346+
Write-Host "##vso[task.setvariable variable=ANDROID_PACK_VERSION;]$($json["version"])"
347+
displayName: Set ANDROID_PACK_VERSION
348+
349+
- pwsh: >-
350+
$(Build.SourcesDirectory)/maui/eng/scripts/update-version-props.ps1
351+
-xmlFileName "$(Build.SourcesDirectory)/maui/eng/Versions.props"
352+
-androidVersion $(ANDROID_PACK_VERSION)
353+
displayName: Update MAUI's Android dependency
354+
355+
- pwsh: ./build.ps1 --target=dotnet --configuration="$(XA.Build.Configuration)" --nugetsource="$(Build.StagingDirectory)\android-packs" --verbosity=diagnostic
356+
displayName: Install .NET
357+
retryCountOnTaskFailure: 3
358+
workingDirectory: $(Build.SourcesDirectory)/maui
359+
360+
- pwsh: ./build.ps1 --target=dotnet-pack --configuration="$(XA.Build.Configuration)" --nugetsource="$(Build.StagingDirectory)\android-packs" --verbosity=diagnostic
361+
displayName: Pack .NET Maui
362+
workingDirectory: $(Build.SourcesDirectory)/maui
363+
364+
- task: DotNetCoreCLI@2
365+
displayName: Install MAUI workload packs
366+
retryCountOnTaskFailure: 3
367+
inputs:
368+
projects: $(Build.SourcesDirectory)/xamarin-android/Xamarin.Android.sln
369+
arguments: -t:InstallMaui -p:MauiUseLocalPacks=true -p:MauiWorkloadToInstall=maui -c $(XA.Build.Configuration) --no-restore -v:n -bl:$(Build.StagingDirectory)/logs/install-maui.binlog
370+
371+
- template: yaml-templates/run-dotnet-preview.yaml
372+
parameters:
373+
command: new
374+
arguments: maui -o $(Build.StagingDirectory)/MauiTestProj
375+
xaSourcePath: $(Build.SourcesDirectory)/xamarin-android
376+
displayName: Create MAUI template
377+
continueOnError: false
378+
379+
- template: yaml-templates/run-dotnet-preview.yaml
380+
parameters:
381+
project: $(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj
382+
arguments: >-
383+
-f $(DotNetTargetFramework)-android -c Debug
384+
--configfile $(Build.SourcesDirectory)/maui/NuGet.config
385+
-bl:$(Build.StagingDirectory)/logs/MauiTestProj-Debug.binlog
386+
xaSourcePath: $(Build.SourcesDirectory)/xamarin-android
387+
displayName: Build MAUI template - Debug
388+
389+
- template: yaml-templates/run-dotnet-preview.yaml
390+
parameters:
391+
project: $(Build.StagingDirectory)/MauiTestProj/MauiTestProj.csproj
392+
arguments: >-
393+
-f $(DotNetTargetFramework)-android -c Release
394+
--configfile $(Build.SourcesDirectory)/maui/NuGet.config
395+
-bl:$(Build.StagingDirectory)/logs/MauiTestProj-Release.binlog
396+
xaSourcePath: $(Build.SourcesDirectory)/xamarin-android
397+
displayName: Build MAUI template - Release
398+
399+
- task: CopyFiles@2
400+
displayName: copy build logs
401+
condition: always()
402+
inputs:
403+
Contents: |
404+
$(Build.SourcesDirectory)/maui/artifacts/logs/**
405+
TargetFolder: $(Build.StagingDirectory)/logs
406+
flattenFolders: true
407+
408+
- template: yaml-templates/publish-artifact.yaml
409+
parameters:
410+
displayName: upload build and test results
411+
artifactName: Test Results - MAUI Integration
412+
targetPath: $(Build.StagingDirectory)/logs
413+
condition: or(ne(variables['Agent.JobStatus'], 'Succeeded'), eq(variables['XA.PublishAllLogs'], 'true'))
414+
415+
- template: yaml-templates/fail-on-issue.yaml
416+
417+
287418
- stage: dotnet_prepare_release
288419
displayName: Prepare .NET Release
289420
dependsOn:

build-tools/scripts/DotNet.targets

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,28 @@
33
<_Root>$(MSBuildThisFileDirectory)..\..\</_Root>
44
<_BinlogPathPrefix>$(_Root)bin/Build$(Configuration)/msbuild-$([System.DateTime]::Now.ToString("yyyyMMddTHHmmss"))</_BinlogPathPrefix>
55
</PropertyGroup>
6+
67
<Target Name="BuildExternal">
78
<Exec
89
Command="&quot;$(DotNetPreviewTool)&quot; build monodroid.proj -c $(Configuration) -p:DebuggingToolsOutputDirectory=$(MicrosoftAndroidSdkOutDir) -p:CompatTargetsOutputDirectory=$(XAInstallPrefix)xbuild/Novell -bl:$(_BinlogPathPrefix)-build-monodroid.binlog"
910
WorkingDirectory="$(_Root)external\monodroid"
1011
/>
1112
</Target>
13+
1214
<Target Name="PrepareJavaInterop">
1315
<Exec
1416
Command="&quot;$(DotNetPreviewTool)&quot; build -t:Prepare Java.Interop.sln -c $(Configuration) -p:JdksRoot=$(JavaSdkDirectory) -p:DotnetToolPath=$(DotNetPreviewTool) -bl:$(_BinlogPathPrefix)-prepare-java-interop.binlog"
1517
WorkingDirectory="$(_Root)external\Java.Interop"
1618
/>
1719
</Target>
20+
1821
<Target Name="BuildDotNet"
1922
DependsOnTargets="PrepareJavaInterop">
2023
<MSBuild Projects="$(_Root)build-tools\xa-prep-tasks\xa-prep-tasks.csproj" />
2124
<MSBuild Projects="$(_Root)Xamarin.Android.sln" Properties="DisableApiCompatibilityCheck=true" />
2225
<MSBuild Projects="$(_Root)build-tools\create-packs\Microsoft.Android.Sdk.proj" Targets="ConfigureLocalWorkload" />
2326
</Target>
27+
2428
<Target Name="PackDotNet">
2529
<!-- Build extra versions of Mono.Android.dll if necessary -->
2630
<MSBuild
@@ -42,34 +46,59 @@
4246
</ItemGroup>
4347
<RemoveDir Directories="@(_DirectoriesToRemove)" />
4448
</Target>
49+
4550
<Target Name="InstallMaui">
46-
<Error Text="%24(MauiVersion) must be specified." Condition=" '$(MauiVersion)' == '' " />
51+
<Error Text="%24(MauiVersion) must be specified." Condition=" '$(MauiVersion)' == '' and '$(MauiUseLocalPacks)' != 'true' " />
4752
<PropertyGroup>
4853
<_TempDirectory>$(DotNetPreviewPath)..\.xa-workload-temp-$([System.IO.Path]::GetRandomFileName())</_TempDirectory>
4954
<MauiVersionBand Condition=" '$(MauiVersionBand)' == '' ">$(DotNetSdkManifestsFolder)</MauiVersionBand>
55+
<MauiUseLocalPacks Condition=" '$(MauiUseLocalPacks)' == '' ">false</MauiUseLocalPacks>
56+
<MauiSourcePath Condition=" '$(MauiSourcePath)' == '' ">$(XamarinAndroidSourcePath)..\maui</MauiSourcePath>
57+
<MauiPackagePath Condition=" '$(MauiPackagePath)' == '' ">$(MauiSourcePath)\artifacts</MauiPackagePath>
58+
<MauiWorkloadToInstall Condition=" '$(MauiWorkloadToInstall)' == '' ">maui-android</MauiWorkloadToInstall>
5059
</PropertyGroup>
5160
<MakeDir Directories="$(_TempDirectory)" />
61+
62+
<!-- Restore or extract WorkloadManifest.* files-->
5263
<Exec
64+
Condition=" '$(MauiUseLocalPacks)' != 'true' "
5365
Command="&quot;$(DotNetPreviewTool)&quot; restore maui.proj -p:MauiVersion=$(MauiVersion) -p:MauiVersionBand=$(MauiVersionBand)"
5466
WorkingDirectory="$(MSBuildThisFileDirectory)"
5567
EnvironmentVariables="NUGET_PACKAGES=$(_TempDirectory);DOTNET_MULTILEVEL_LOOKUP=0"
5668
/>
69+
<ItemGroup>
70+
<_WLManifestPack Include="$(MauiPackagePath)\Microsoft.NET.Sdk.Maui.Manifest-$(MauiVersionBand.Substring (0,3))*.nupkg" />
71+
</ItemGroup>
72+
<Unzip
73+
Condition=" '$(MauiUseLocalPacks)' == 'true' "
74+
SourceFiles="@(_WLManifestPack)"
75+
DestinationFolder="$(_TempDirectory)"
76+
/>
5777

5878
<!-- Copy WorkloadManifest.* files-->
5979
<ItemGroup>
60-
<_WLManifest Include="$(_TempDirectory)\microsoft.net.sdk.maui.manifest-$(MauiVersionBand)\$(MauiVersion)\data\WorkloadManifest.*" />
80+
<_WLManifest Condition=" '$(MauiUseLocalPacks)' != 'true' " Include="$(_TempDirectory)\microsoft.net.sdk.maui.manifest-$(MauiVersionBand)\$(MauiVersion)\data\WorkloadManifest.*" />
81+
<_WLManifest Condition=" '$(MauiUseLocalPacks)' == 'true' " Include="$(_TempDirectory)\data\*" />
6182
</ItemGroup>
6283
<Copy SourceFiles="@(_WLManifest)" DestinationFolder="$(DotNetPreviewPath)sdk-manifests\$(DotNetSdkManifestsFolder)\microsoft.net.sdk.maui" />
6384

6485
<!-- Parse NuGet.config -->
6586
<XmlPeek
87+
Condition=" '$(MauiUseLocalPacks)' != 'true' "
6688
XmlInputPath="$(XamarinAndroidSourcePath)NuGet.config"
6789
Query="/configuration/packageSources/add/@value">
6890
<Output TaskParameter="Result" ItemName="_NuGetSources" />
6991
</XmlPeek>
92+
<XmlPeek
93+
Condition=" '$(MauiUseLocalPacks)' == 'true' "
94+
XmlInputPath="$(MauiSourcePath)\NuGet.config"
95+
Query="/configuration/packageSources/add/@value">
96+
<Output TaskParameter="Result" ItemName="_NuGetSources" />
97+
</XmlPeek>
7098

7199
<!-- dotnet workload install maui-android -->
72100
<ItemGroup>
101+
<_NuGetSources Condition=" '$(MauiUseLocalPacks)' == 'true' " Include="$(MauiPackagePath.TrimEnd('\'))" />
73102
<_NuGetSources Include="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json" />
74103
<_NuGetSources Include="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
75104
<_InstallArguments Include="--skip-manifest-update" />
@@ -78,7 +107,7 @@
78107
<_InstallArguments Include="--temp-dir &quot;$(_TempDirectory)&quot;" />
79108
</ItemGroup>
80109
<Exec
81-
Command="&quot;$(DotNetPreviewTool)&quot; workload install maui-android @(_InstallArguments, ' ')"
110+
Command="&quot;$(DotNetPreviewTool)&quot; workload install $(MauiWorkloadToInstall) @(_InstallArguments, ' ')"
82111
WorkingDirectory="$(_TempDirectory)"
83112
EnvironmentVariables="DOTNET_MULTILEVEL_LOOKUP=0"
84113
/>

0 commit comments

Comments
 (0)