Skip to content

Commit 0150bbb

Browse files
[One .NET] extend the microsoft-net-runtime-android workload (dotnet#5975)
Context: https://github.com/dotnet/runtime/blob/d43e88620fe574045f026a4ebce50f7a8541347a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in In order to start using packs from the `microsoft-net-runtime-android` workload, we need to: 1. Add `Microsoft.NET.Workload.Mono.ToolChain.Manifest-6.0.100` to `package-download.proj`. 2. Copy `WorkloadManifest.*` files from: Microsoft.NET.Workload.Mono.ToolChain.Manifest-6.0.100/data/ To: ~/android-toolchain/dotnet/sdk-manifests/6.0.100/Microsoft.NET.Workload.Mono.ToolChain/ So we get the latest `WorkloadManifest.json` based on the version defined in `$(MicrosoftNETCoreAppRefPackageVersion)`. 3. `xaprepare` should run: ~/android-toolchain/dotnet/dotnet workload install microsoft-net-runtime-android --skip-manifest-update --verbosity diag So the packs are installed for local development and CI. 4. Our workload should "extend" `microsoft-net-runtime-android`. This would make sure these packs are installed on user's machines.
1 parent 19796bb commit 0150bbb

File tree

7 files changed

+34
-2
lines changed

7 files changed

+34
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ static class KnownProperties
2121
public const string CommandLineToolsVersion = nameof (CommandLineToolsVersion);
2222
public const string CommandLineToolsFolder = nameof (CommandLineToolsFolder);
2323
public const string DotNetPreviewPath = "DotNetPreviewPath";
24+
public const string DotNetPreviewVersionBand = nameof (DotNetPreviewVersionBand);
2425
public const string MicrosoftDotnetSdkInternalPackageVersion = "MicrosoftDotnetSdkInternalPackageVersion";
2526
public const string MicrosoftNETCoreAppRefPackageVersion = "MicrosoftNETCoreAppRefPackageVersion";
2627
public const string EmulatorVersion = "EmulatorVersion";

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace Xamarin.Android.Prepare
2525
properties.Add (KnownProperties.CommandLineToolsFolder, StripQuotes ("@CommandLineToolsFolder@"));
2626
properties.Add (KnownProperties.CommandLineToolsVersion, StripQuotes ("@CommandLineToolsVersion@"));
2727
properties.Add (KnownProperties.DotNetPreviewPath, StripQuotes (@"@DotNetPreviewPath@"));
28+
properties.Add (KnownProperties.DotNetPreviewVersionBand, StripQuotes (@"@DotNetPreviewVersionBand@"));
2829
properties.Add (KnownProperties.MicrosoftDotnetSdkInternalPackageVersion, StripQuotes ("@MicrosoftDotnetSdkInternalPackageVersion@"));
2930
properties.Add (KnownProperties.MicrosoftNETCoreAppRefPackageVersion, StripQuotes ("@MicrosoftNETCoreAppRefPackageVersion@"));
3031
properties.Add (KnownProperties.EmulatorVersion, StripQuotes ("@EmulatorVersion@"));

build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,13 @@ public static partial class Paths
380380
public static string NetcoreAppRuntimeAndroidX86 => GetCachedPath (ref netcoreAppRuntimeAndroidX86, () => GetNetcoreAppRuntimePath (ctx, "x86"));
381381
public static string NetcoreAppRuntimeAndroidX86_64 => GetCachedPath (ref netcoreAppRuntimeAndroidX86_64, () => GetNetcoreAppRuntimePath (ctx, "x64"));
382382

383+
public static string MicrosoftNETWorkloadMonoToolChainDir => Path.Combine (
384+
XAPackagesDir,
385+
$"microsoft.net.workload.mono.toolchain.manifest-{ctx.Properties.GetRequiredValue (KnownProperties.DotNetPreviewVersionBand)}",
386+
ctx.Properties.GetRequiredValue (KnownProperties.MicrosoftNETCoreAppRefPackageVersion),
387+
"data"
388+
);
389+
383390
// CMake
384391
public static string CmakeMSBuildPropsName = "cmake-config.props";
385392
public static string CmakeShellScriptsPropsName = "cmake-config.sh";

build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,27 @@ protected override async Task<bool> Execute (Context context)
8888
// Install runtime packs associated with the SDK previously installed.
8989
var packageDownloadProj = Path.Combine (BuildPaths.XamarinAndroidSourceRoot, "build-tools", "xaprepare", "xaprepare", "package-download.proj");
9090
var logPath = Path.Combine (Configurables.Paths.BuildBinDir, $"msbuild-{context.BuildTimeStamp}-download-runtime-packs.binlog");
91-
return Utilities.RunCommand (dotnetTool, new string [] { "restore", ProcessRunner.QuoteArgument (packageDownloadProj), ProcessRunner.QuoteArgument ($"-bl:{logPath}") });
91+
if (!Utilities.RunCommand (dotnetTool, new string [] { "restore", ProcessRunner.QuoteArgument (packageDownloadProj), ProcessRunner.QuoteArgument ($"-bl:{logPath}") })) {
92+
Log.ErrorLine ($"dotnet restore {packageDownloadProj} failed.");
93+
return false;
94+
}
95+
96+
// Copy the WorkloadManifest.* files from the latest Microsoft.NET.Workload.Mono.ToolChain listed in package-download.proj
97+
var destination = Path.Combine (dotnetPath, "sdk-manifests",
98+
context.Properties.GetRequiredValue (KnownProperties.DotNetPreviewVersionBand),
99+
"Microsoft.NET.Workload.Mono.ToolChain"
100+
);
101+
foreach (var file in Directory.GetFiles (Configurables.Paths.MicrosoftNETWorkloadMonoToolChainDir, "WorkloadManifest.*")) {
102+
Utilities.CopyFileToDir (file, destination);
103+
}
104+
105+
// Install the microsoft-net-runtime-android workload
106+
if (!Utilities.RunCommand (dotnetTool, new [] { "workload", "install", "microsoft-net-runtime-android", "--skip-manifest-update", "--verbosity", "diag" })) {
107+
Log.ErrorLine ($"dotnet workload install failed.");
108+
return false;
109+
}
110+
111+
return true;
92112
}
93113

94114
async Task<bool> InstallDotNetAsync (Context context, string dotnetPath, string version, bool runtimeOnly = false)

build-tools/xaprepare/xaprepare/package-download.proj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Otherwise, $(MicrosoftNETCoreAppRefPackageVersion) from eng/Versions.props will
2020
<PackageDownload Include="Microsoft.NETCore.App.Runtime.Mono.android-arm64" Version="[$(DotNetRuntimePacksVersion)]" />
2121
<PackageDownload Include="Microsoft.NETCore.App.Runtime.Mono.android-x86" Version="[$(DotNetRuntimePacksVersion)]" />
2222
<PackageDownload Include="Microsoft.NETCore.App.Runtime.Mono.android-x64" Version="[$(DotNetRuntimePacksVersion)]" />
23+
<PackageDownload Include="Microsoft.NET.Workload.Mono.ToolChain.Manifest-$(DotNetPreviewVersionBand)" Version="[$(DotNetRuntimePacksVersion)]" />
2324
</ItemGroup>
2425

2526
</Project>

build-tools/xaprepare/xaprepare/xaprepare.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
<Replacement Include="@CommandLineToolsFolder@=$(CommandLineToolsFolder)" />
6060
<Replacement Include="@CommandLineToolsVersion@=$(CommandLineToolsVersion)" />
6161
<Replacement Include="@DotNetPreviewPath@=$(DotNetPreviewPath)" />
62+
<Replacement Include="@DotNetPreviewVersionBand@=$(DotNetPreviewVersionBand)" />
6263
<Replacement Include="@MicrosoftDotnetSdkInternalPackageVersion@=$(MicrosoftDotnetSdkInternalPackageVersion)" />
6364
<Replacement Include="@MicrosoftNETCoreAppRefPackageVersion@=$(MicrosoftNETCoreAppRefPackageVersion)" />
6465
<Replacement Include="@EmulatorVersion@=$(EmulatorVersion)" />

src/Xamarin.Android.Build.Tasks/Microsoft.NET.Sdk.Android/WorkloadManifest.in.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"Microsoft.Android.Sdk.BundleTool",
99
"Microsoft.Android.Ref",
1010
"Microsoft.Android.Templates"
11-
]
11+
],
12+
"extends" : [ "microsoft-net-runtime-android" ]
1213
}
1314
},
1415
"packs": {

0 commit comments

Comments
 (0)