Skip to content

Commit cdc35b6

Browse files
authored
[ci] Move .NET preview installation to xaprepare (#5191)
Context: https://github.com/dotnet/designs/blob/main/accepted/2020/workloads/workloads.md For .NET 6, our .NET 6 installer payload content will be distributed through a new "Optional Workload" concept. Early support for workloads has now landed in VS and the .NET SDK, and we'd like to begin to convert our monolithic MSBuild SDK NuGet into various workload packs. In an effort to support dev and test efforts to this end, it will be helpful to introduce a non-system installation of .NET that we can modify freely without admin access or fear of leaving machines in a broken state. Update the `xaprepare -s:Standard` scenario to install multiple `dotnet` versions into `$(DotNetPreviewPath)`, which defaults to `$(AndroidToolchainDirectory)\dotnet`. The currently installed `dotnet` versions are: * 3.1.3: Stable version, for some tests. * 5.0.100-rc.2.20480.7: Preview .NET 5 RC which contains support for the Optional Workload concept.
1 parent 84f999f commit cdc35b6

File tree

21 files changed

+191
-84
lines changed

21 files changed

+191
-84
lines changed

Configuration.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@
6767
<AndroidMxeInstallPrefix Condition=" '$(HostOS)' == 'Darwin' ">$(HostHomebrewPrefix)</AndroidMxeInstallPrefix>
6868
<AndroidSdkDirectory Condition=" '$(AndroidSdkDirectory)' == '' ">$(AndroidToolchainDirectory)\sdk</AndroidSdkDirectory>
6969
<AndroidNdkDirectory Condition=" '$(AndroidNdkDirectory)' == '' ">$(AndroidToolchainDirectory)\ndk</AndroidNdkDirectory>
70+
<DotNetPreviewPath Condition=" '$(DotNetPreviewPath)' == '' ">$(AndroidToolchainDirectory)\dotnet\</DotNetPreviewPath>
71+
<DotNetPreviewTool Condition=" '$(DotNetPreviewTool)' == '' ">$(DotNetPreviewPath)dotnet</DotNetPreviewTool>
7072
<AndroidCmakeVersion Condition=" '$(AndroidCmakeVersion)' == '' ">3.10.2</AndroidCmakeVersion>
7173
<AndroidCmakeVersionPath Condition=" '$(AndroidCmakeVersionPath)' == '' ">$(AndroidCmakeVersion).4988404</AndroidCmakeVersionPath>
7274
<AndroidSdkCmakeDirectory>$(AndroidSdkDirectory)\cmake\$(AndroidCmakeVersionPath)</AndroidSdkCmakeDirectory>

build-tools/automation/azure-pipelines-oss.yaml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,8 @@ variables:
2727
EXTRA_MSBUILD_ARGS: /p:AutoProvision=True /p:AutoProvisionUsesSudo=True /p:IgnoreMaxMonoVersion=False
2828
PREPARE_FLAGS: PREPARE_CI=1 PREPARE_CI_PR=1
2929
DotNetCoreVersion: 3.1.201
30-
# Version number from: https://github.com/dotnet/installer#installers-and-binaries
31-
DotNetCorePreviewVersion: 5.0.100-rc.2.20459.1
3230
GitHub.Token: $(github--pat--vs-mobiletools-engineering-service2)
3331

34-
3532
stages:
3633
- stage: mac_stage
3734
displayName: Mac
@@ -52,13 +49,9 @@ stages:
5249
clean: true # Executes: git clean -ffdx && git reset --hard HEAD
5350
submodules: recursive
5451

55-
- template: yaml-templates/use-dot-net.yaml
56-
parameters:
57-
version: $(DotNetCorePreviewVersion)
58-
remove_dotnet: true
59-
60-
- template: yaml-templates/use-dot-net.yaml
61-
parameters:
52+
- task: UseDotNet@2
53+
displayName: install .NET Core $(DotNetCoreVersion)
54+
inputs:
6255
version: $(DotNetCoreVersion)
6356

6457
- bash: |

build-tools/automation/azure-pipelines.yaml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ variables:
5252
TestAssembliesArtifactName: test-assemblies
5353
NUnitConsoleVersion: 3.11.1
5454
DotNetCoreVersion: 3.1.201
55-
# Version number from: https://github.com/dotnet/installer#installers-and-binaries
56-
DotNetCorePreviewVersion: 5.0.100-rc.2.20480.7
5755
HostedMacMojave: Hosted Mac Internal Mojave
5856
HostedMac: Hosted Mac Internal
5957
HostedWinVS2019: Hosted Windows 2019 with VS2019
@@ -137,13 +135,9 @@ stages:
137135
- script: echo "##vso[task.setvariable variable=JI_JAVA_HOME]$HOME/Library/Android/$(XA.Jdk11.Folder)"
138136
displayName: set JI_JAVA_HOME
139137

140-
- template: yaml-templates/use-dot-net.yaml
141-
parameters:
142-
version: $(DotNetCorePreviewVersion)
143-
remove_dotnet: true
144-
145-
- template: yaml-templates/use-dot-net.yaml
146-
parameters:
138+
- task: UseDotNet@2
139+
displayName: install .NET Core $(DotNetCoreVersion)
140+
inputs:
147141
version: $(DotNetCoreVersion)
148142

149143
- template: install-certificates.yml@yaml
@@ -287,13 +281,9 @@ stages:
287281
echo ##vso[task.setvariable variable=JI_JAVA_HOME]%USERPROFILE%\android-toolchain\$(XA.Jdk11.Folder)
288282
displayName: set JI_JAVA_HOME
289283
290-
- template: yaml-templates\use-dot-net.yaml
291-
parameters:
292-
version: $(DotNetCorePreviewVersion)
293-
remove_dotnet: true
294-
295-
- template: yaml-templates\use-dot-net.yaml
296-
parameters:
284+
- task: UseDotNet@2
285+
displayName: install .NET Core $(DotNetCoreVersion)
286+
inputs:
297287
version: $(DotNetCoreVersion)
298288

299289
# Downgrade the XA .vsix installed into the instance of VS that we are building with so that we don't restore/build against a test version.

build-tools/automation/yaml-templates/run-nunit-tests.yaml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,22 @@ parameters:
1111

1212
steps:
1313
- powershell: |
14-
if ("${{ parameters.useDotNet }}" -eq $true) {
15-
Write-Host '##vso[task.setvariable variable=TestResultsFormat]VSTest'
16-
dotnet test ${{ parameters.testAssembly }} --results-directory . --logger "trx;LogFileName=${{ parameters.testResultsFile }}" ${{ parameters.dotNetTestExtraArgs }} -- NUnit.NumberOfTestWorkers=${{ parameters.workers }}
17-
} elseif ([Environment]::OSVersion.Platform -eq "Unix") {
18-
Write-Host '##vso[task.setvariable variable=TestResultsFormat]NUnit'
19-
mono ${{ parameters.nunitConsole }} ${{ parameters.testAssembly }} --result ${{ parameters.testResultsFile }} --workers=${{ parameters.workers }} ${{ parameters.nunitConsoleExtraArgs }}
14+
if ([Environment]::OSVersion.Platform -eq "Unix") {
15+
if ("${{ parameters.useDotNet }}" -eq $true) {
16+
Write-Host '##vso[task.setvariable variable=TestResultsFormat]VSTest'
17+
& $env:HOME/Library/Android/dotnet/dotnet test ${{ parameters.testAssembly }} --results-directory . --logger "trx;LogFileName=${{ parameters.testResultsFile }}" ${{ parameters.dotNetTestExtraArgs }} -- NUnit.NumberOfTestWorkers=${{ parameters.workers }}
18+
} else {
19+
Write-Host '##vso[task.setvariable variable=TestResultsFormat]NUnit'
20+
mono ${{ parameters.nunitConsole }} ${{ parameters.testAssembly }} --result ${{ parameters.testResultsFile }} --workers=${{ parameters.workers }} ${{ parameters.nunitConsoleExtraArgs }}
21+
}
2022
} else {
21-
Write-Host '##vso[task.setvariable variable=TestResultsFormat]NUnit'
22-
${{ parameters.nunitConsole }} ${{ parameters.testAssembly }} --result ${{ parameters.testResultsFile }} --workers=${{ parameters.workers }} ${{ parameters.nunitConsoleExtraArgs }}
23+
if ("${{ parameters.useDotNet }}" -eq $true) {
24+
Write-Host '##vso[task.setvariable variable=TestResultsFormat]VSTest'
25+
& $env:USERPROFILE\android-toolchain\dotnet\dotnet.exe test ${{ parameters.testAssembly }} --results-directory . --logger "trx;LogFileName=${{ parameters.testResultsFile }}" ${{ parameters.dotNetTestExtraArgs }} -- NUnit.NumberOfTestWorkers=${{ parameters.workers }}
26+
} else {
27+
Write-Host '##vso[task.setvariable variable=TestResultsFormat]NUnit'
28+
${{ parameters.nunitConsole }} ${{ parameters.testAssembly }} --result ${{ parameters.testResultsFile }} --workers=${{ parameters.workers }} ${{ parameters.nunitConsoleExtraArgs }}
29+
}
2330
}
2431
if ($LASTEXITCODE -ne 0) {
2532
Write-Host "##vso[task.logissue type=error]Test suite had $LASTEXITCODE failure(s)."

build-tools/automation/yaml-templates/setup-test-environment.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,9 @@ steps:
2121
displayName: set JI_JAVA_HOME
2222
condition: and(succeeded(), eq(variables['agent.os'], 'Windows_NT'))
2323

24-
- template: use-dot-net.yaml
25-
parameters:
26-
version: $(DotNetCorePreviewVersion)
27-
remove_dotnet: true
28-
29-
- template: use-dot-net.yaml
30-
parameters:
24+
- task: UseDotNet@2
25+
displayName: install .NET Core $(DotNetCoreVersion)
26+
inputs:
3127
version: $(DotNetCoreVersion)
3228

3329
- script: |

build-tools/automation/yaml-templates/use-dot-net.yaml

Lines changed: 0 additions & 33 deletions
This file was deleted.

build-tools/create-packs/Directory.Build.targets

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@
5252
</Target>
5353

5454
<Target Name="CreateAllRuntimePacks" >
55-
<Exec Command="dotnet pack -p:Configuration=$(Configuration) -p:AndroidRID=android.21-arm -p:AndroidABI=armeabi-v7a &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
56-
<Exec Command="dotnet pack -p:Configuration=$(Configuration) -p:AndroidRID=android.21-arm64 -p:AndroidABI=arm64-v8a &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
57-
<Exec Command="dotnet pack -p:Configuration=$(Configuration) -p:AndroidRID=android.21-x86 -p:AndroidABI=x86 &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
58-
<Exec Command="dotnet pack -p:Configuration=$(Configuration) -p:AndroidRID=android.21-x64 -p:AndroidABI=x86_64 &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
55+
<Exec Command="$(DotNetPreviewTool) pack -p:Configuration=$(Configuration) -p:AndroidRID=android.21-arm -p:AndroidABI=armeabi-v7a &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
56+
<Exec Command="$(DotNetPreviewTool) pack -p:Configuration=$(Configuration) -p:AndroidRID=android.21-arm64 -p:AndroidABI=arm64-v8a &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
57+
<Exec Command="$(DotNetPreviewTool) pack -p:Configuration=$(Configuration) -p:AndroidRID=android.21-x86 -p:AndroidABI=x86 &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
58+
<Exec Command="$(DotNetPreviewTool) pack -p:Configuration=$(Configuration) -p:AndroidRID=android.21-x64 -p:AndroidABI=x86_64 &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
5959
</Target>
6060

6161
<Target Name="CreateAllPacks"
6262
DependsOnTargets="CreateAllRuntimePacks" >
63-
<Exec Command="dotnet pack -p:Configuration=$(Configuration) &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Ref.proj&quot;" />
64-
<Exec Command="dotnet pack -p:Configuration=$(Configuration) &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Sdk.proj&quot;" />
65-
<Exec Command="dotnet pack -p:Configuration=$(Configuration) &quot;$(MSBuildThisFileDirectory)Xamarin.Android.Sdk.Lite.proj&quot;" />
63+
<Exec Command="$(DotNetPreviewTool) pack -p:Configuration=$(Configuration) &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Ref.proj&quot;" />
64+
<Exec Command="$(DotNetPreviewTool) pack -p:Configuration=$(Configuration) &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Sdk.proj&quot;" />
65+
<Exec Command="$(DotNetPreviewTool) pack -p:Configuration=$(Configuration) &quot;$(MSBuildThisFileDirectory)Xamarin.Android.Sdk.Lite.proj&quot;" />
6666
</Target>
6767

6868
</Project>

build-tools/scripts/Paths.targets

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,10 @@
3737
Importance="High"
3838
/>
3939
</Target>
40+
<Target Name="GetDotNetPreviewPath">
41+
<Message
42+
Text="$(DotNetPreviewPath)"
43+
Importance="High"
44+
/>
45+
</Target>
4046
</Project>

build-tools/xaprepare/xaprepare/Application/KnownProperties.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ static class KnownProperties
1818
public const string Configuration = "Configuration";
1919
public const string CommandLineToolsVersion = nameof (CommandLineToolsVersion);
2020
public const string CommandLineToolsFolder = nameof (CommandLineToolsFolder);
21+
public const string DotNetPreviewPath = "DotNetPreviewPath";
2122
public const string EmulatorVersion = "EmulatorVersion";
2223
public const string EmulatorPkgRevision = "EmulatorPkgRevision";
2324
public const string IgnoreMaxMonoVersion = "IgnoreMaxMonoVersion";

build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace Xamarin.Android.Prepare
2222
properties.Add (KnownProperties.Configuration, StripQuotes ("@Configuration@"));
2323
properties.Add (KnownProperties.CommandLineToolsFolder, StripQuotes ("@CommandLineToolsFolder@"));
2424
properties.Add (KnownProperties.CommandLineToolsVersion, StripQuotes ("@CommandLineToolsVersion@"));
25+
properties.Add (KnownProperties.DotNetPreviewPath, StripQuotes (@"@DotNetPreviewPath@"));
2526
properties.Add (KnownProperties.EmulatorVersion, StripQuotes ("@EmulatorVersion@"));
2627
properties.Add (KnownProperties.EmulatorPkgRevision, StripQuotes ("@EmulatorPkgRevision@"));
2728
properties.Add (KnownProperties.IgnoreMaxMonoVersion, StripQuotes ("@IgnoreMaxMonoVersion@"));

0 commit comments

Comments
 (0)