diff --git a/Makefile b/Makefile
index 85c28361c68..d4e62485ff9 100644
--- a/Makefile
+++ b/Makefile
@@ -121,11 +121,16 @@ list-nunit-tests:
include build-tools/scripts/runtime-helpers.mk
.PHONY: prepare
-prepare:
+prepare: install-dotnet
$(call SYSTEM_DOTNET_BINLOG,prepare-run,run) $(PREPARE_MSBUILD_FLAGS) --project "$(PREPARE_PROJECT)" --framework $(PREPARE_NET_FX) -- $(_PREPARE_ARGS)
$(call SYSTEM_DOTNET_BINLOG,prepare-bootstrap) Xamarin.Android.BootstrapTasks.sln
+ $(call SYSTEM_DOTNET_BINLOG,prepare-workloads) src/workloads/workloads.csproj
$(call DOTNET_BINLOG,prepare-java.interop) $(SOLUTION) -t:PrepareJavaInterop
+.PHONY: install-dotnet
+install-dotnet:
+ bash ./eng/install-dotnet.sh
+
.PHONY: prepare-help
prepare-help:
$(call SYSTEM_DOTNET_BINLOG,prepare-help,run) --project "$(PREPARE_PROJECT)" --framework $(PREPARE_NET_FX) -- -h
diff --git a/build-tools/automation/azure-pipelines-nightly.yaml b/build-tools/automation/azure-pipelines-nightly.yaml
index 97811fe5a0a..12733b86759 100644
--- a/build-tools/automation/azure-pipelines-nightly.yaml
+++ b/build-tools/automation/azure-pipelines-nightly.yaml
@@ -118,7 +118,6 @@ stages:
steps:
- template: /build-tools/automation/yaml-templates/setup-test-environment.yaml
parameters:
- xaprepareScenario: EmulatorTestDependencies
jdkMajorVersion: $(LatestJavaSdkMajorVersion)
- template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml
@@ -194,7 +193,6 @@ stages:
- template: /build-tools/automation/yaml-templates/setup-test-environment.yaml
parameters:
installTestSlicer: true
- xaprepareScenario: EmulatorTestDependencies
useAgentJdkPath: false
jdkMajorVersion: $(LatestJavaSdkMajorVersion)
@@ -247,7 +245,6 @@ stages:
- template: /build-tools/automation/yaml-templates/setup-test-environment.yaml
parameters:
installTestSlicer: true
- xaprepareScenario: EmulatorTestDependencies
useAgentJdkPath: false
jdkMajorVersion: $(LatestJavaSdkMajorVersion)
diff --git a/build-tools/automation/azure-pipelines-public.yaml b/build-tools/automation/azure-pipelines-public.yaml
index a2f83418def..95cf055f6ca 100644
--- a/build-tools/automation/azure-pipelines-public.yaml
+++ b/build-tools/automation/azure-pipelines-public.yaml
@@ -379,7 +379,6 @@ stages:
parameters:
installTestSlicer: true
installApkDiff: false
- xaprepareScenario: EmulatorTestDependencies
use1ESTemplate: false
- task: DownloadPipelineArtifact@2
diff --git a/build-tools/automation/yaml-templates/run-emulator-tests.yaml b/build-tools/automation/yaml-templates/run-emulator-tests.yaml
index 82f583343b9..2ce355278c0 100644
--- a/build-tools/automation/yaml-templates/run-emulator-tests.yaml
+++ b/build-tools/automation/yaml-templates/run-emulator-tests.yaml
@@ -26,7 +26,6 @@ jobs:
- template: /build-tools/automation/yaml-templates/setup-test-environment.yaml
parameters:
- xaprepareScenario: EmulatorTestDependencies
jdkMajorVersion: ${{ parameters.jdkMajorVersion }}
useAgentJdkPath: ${{ parameters.useAgentJdkPath }}
use1ESTemplate: ${{ parameters.use1ESTemplate }}
diff --git a/build-tools/automation/yaml-templates/run-xaprepare.yaml b/build-tools/automation/yaml-templates/run-xaprepare.yaml
deleted file mode 100644
index 209aab8219d..00000000000
--- a/build-tools/automation/yaml-templates/run-xaprepare.yaml
+++ /dev/null
@@ -1,17 +0,0 @@
-parameters:
- displayName: run xaprepare
- name:
- configuration: $(XA.Build.Configuration)
- xaSourcePath: $(System.DefaultWorkingDirectory)
- condition: succeeded()
- arguments:
-
-steps:
-- task: DotNetCoreCLI@2
- displayName: ${{ parameters.displayName }}
- name: ${{ parameters.name }}
- condition: ${{ parameters.condition }}
- inputs:
- command: run
- projects: ${{ parameters.xaSourcePath }}/build-tools/xaprepare/xaprepare/xaprepare.csproj
- arguments: -f $(DotNetStableTargetFramework) -c ${{ parameters.configuration }} -- ${{ parameters.arguments }} --no-emoji --run-mode=CI
diff --git a/build-tools/automation/yaml-templates/setup-test-environment-public.yaml b/build-tools/automation/yaml-templates/setup-test-environment-public.yaml
index 85b6c2ff7b0..b0cfeaaceb5 100644
--- a/build-tools/automation/yaml-templates/setup-test-environment-public.yaml
+++ b/build-tools/automation/yaml-templates/setup-test-environment-public.yaml
@@ -14,7 +14,6 @@ parameters:
androidSdkPlatforms: $(DefaultTestSdkPlatforms)
repositoryAlias: 'self'
commit: ''
- xaprepareScenario: AndroidTestDependencies # Use 'EmulatorTestDependencies' for agents that need the emulator installed
use1ESTemplate: false
steps:
@@ -36,5 +35,4 @@ steps:
installTestSlicer: ${{ parameters.installTestSlicer }}
installApkDiff: ${{ parameters.installApkDiff }}
androidSdkPlatforms: ${{ parameters.androidSdkPlatforms }}
- xaprepareScenario: ${{ parameters.xaprepareScenario }}
use1ESTemplate: false
diff --git a/build-tools/automation/yaml-templates/setup-test-environment-steps.yaml b/build-tools/automation/yaml-templates/setup-test-environment-steps.yaml
index 78c8c8cb892..04925a43fc2 100644
--- a/build-tools/automation/yaml-templates/setup-test-environment-steps.yaml
+++ b/build-tools/automation/yaml-templates/setup-test-environment-steps.yaml
@@ -12,7 +12,6 @@ parameters:
installTestSlicer: false
installApkDiff: true
androidSdkPlatforms: $(DefaultTestSdkPlatforms)
- xaprepareScenario: AndroidTestDependencies # Use 'EmulatorTestDependencies' for agents that need the emulator installed
use1ESTemplate: true
steps:
@@ -50,10 +49,25 @@ steps:
displayName: Install p7zip on macOS
condition: and(succeeded(), eq(variables['agent.os'], 'Darwin'))
-- template: /build-tools/automation/yaml-templates/run-xaprepare.yaml
- parameters:
- arguments: --s=${{ parameters.xaprepareScenario }}
- xaSourcePath: ${{ parameters.xaSourcePath }}
+- pwsh: |
+ & "${{ parameters.xaSourcePath }}/eng/install-dotnet.ps1" -configuration ${{ parameters.configuration }}
+ if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
+ displayName: install .NET SDK to bin/${{ parameters.configuration }}/dotnet
+ condition: and(succeeded(), eq(variables['agent.os'], 'Windows_NT'))
+
+- bash: |
+ set -e
+ bash "${{ parameters.xaSourcePath }}/eng/install-dotnet.sh"
+ displayName: install .NET SDK to bin/${{ parameters.configuration }}/dotnet
+ condition: and(succeeded(), ne(variables['agent.os'], 'Windows_NT'))
+ env:
+ CONFIGURATION: ${{ parameters.configuration }}
+
+- task: DotNetCoreCLI@2
+ displayName: prepare .NET workloads
+ inputs:
+ projects: ${{ parameters.xaSourcePath }}/src/workloads/workloads.csproj
+ arguments: -c ${{ parameters.configuration }} -bl:${{ parameters.xaSourcePath }}/bin/Test${{ parameters.configuration }}/workloads.binlog
- task: DotNetCoreCLI@2
displayName: build Xamarin.Android.Tools.BootstrapTasks.csproj
diff --git a/build-tools/automation/yaml-templates/setup-test-environment.yaml b/build-tools/automation/yaml-templates/setup-test-environment.yaml
index b20a666e62b..da0f137e9df 100644
--- a/build-tools/automation/yaml-templates/setup-test-environment.yaml
+++ b/build-tools/automation/yaml-templates/setup-test-environment.yaml
@@ -11,7 +11,6 @@ parameters:
androidSdkPlatforms: $(DefaultTestSdkPlatforms)
repositoryAlias: 'self'
commit: ''
- xaprepareScenario: AndroidTestDependencies # Use 'EmulatorTestDependencies' for agents that need the emulator installed
use1ESTemplate: true
steps:
@@ -41,5 +40,4 @@ steps:
installTestSlicer: ${{ parameters.installTestSlicer }}
installApkDiff: ${{ parameters.installApkDiff }}
androidSdkPlatforms: ${{ parameters.androidSdkPlatforms }}
- xaprepareScenario: ${{ parameters.xaprepareScenario }}
use1ESTemplate: ${{ parameters.use1ESTemplate }}
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 abf8564a24d..f8cc3c3b887 100644
--- a/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml
+++ b/build-tools/automation/yaml-templates/stage-msbuild-emulator-tests.yaml
@@ -41,7 +41,6 @@ stages:
xaSourcePath: ${{ parameters.xaSourcePath }}
repositoryAlias: ${{ parameters.repositoryAlias }}
commit: ${{ parameters.commit }}
- xaprepareScenario: EmulatorTestDependencies
use1ESTemplate: ${{ parameters.use1ESTemplate }}
- task: DownloadPipelineArtifact@2
diff --git a/build-tools/automation/yaml-templates/stage-package-tests.yaml b/build-tools/automation/yaml-templates/stage-package-tests.yaml
index e6fd01de65f..e3ee63e5995 100644
--- a/build-tools/automation/yaml-templates/stage-package-tests.yaml
+++ b/build-tools/automation/yaml-templates/stage-package-tests.yaml
@@ -23,7 +23,6 @@ stages:
steps:
- template: /build-tools/automation/yaml-templates/setup-test-environment.yaml
parameters:
- xaprepareScenario: EmulatorTestDependencies
use1ESTemplate: ${{ parameters.use1ESTemplate }}
- task: DownloadPipelineArtifact@2
@@ -120,7 +119,6 @@ stages:
steps:
- template: /build-tools/automation/yaml-templates/setup-test-environment.yaml
parameters:
- xaprepareScenario: EmulatorTestDependencies
use1ESTemplate: ${{ parameters.use1ESTemplate }}
- task: DownloadPipelineArtifact@2
diff --git a/build-tools/scripts/PrepareWindows.targets b/build-tools/scripts/PrepareWindows.targets
index bcd6144a4f3..a9280e76850 100644
--- a/build-tools/scripts/PrepareWindows.targets
+++ b/build-tools/scripts/PrepareWindows.targets
@@ -9,7 +9,13 @@
<_XAPrepareStandardArgs Condition=" '$(XA_FORCE_COMPONENT_REFRESH)' == 'true' ">$(_XAPrepareStandardArgs) -refresh
-
+
+
+
+
+
diff --git a/build-tools/xaprepare/xaprepare/Application/Context.cs b/build-tools/xaprepare/xaprepare/Application/Context.cs
index d56517a0ffb..b112f5f5864 100644
--- a/build-tools/xaprepare/xaprepare/Application/Context.cs
+++ b/build-tools/xaprepare/xaprepare/Application/Context.cs
@@ -277,11 +277,6 @@ public string DebugFileExtension {
}
}
- ///
- /// Path to a local .NET SDK archive to use instead of downloading.
- ///
- public string? LocalDotNetSdkArchive { get; set; }
-
///
/// Determines whether or not we are running on a hosted azure pipelines agent.
/// These agents have certain limitations, the most pressing being the amount of available storage.
diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.Unix.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.Unix.cs
index 01b91fbcf68..b1654a89b42 100644
--- a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.Unix.cs
+++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.Unix.cs
@@ -9,14 +9,5 @@ partial class Defaults
{
public const string DefaultCompiler = "cc";
}
-
- partial class Urls
- {
- // This is the "public" url that we really should be using, but it keeps failing with:
- // AuthenticationException: The remote certificate is invalid because of errors in the certificate chain: RevocationStatusUnknown
- // For now we'll grab it directly from GitHub
- // public static readonly Uri DotNetInstallScript = new Uri ("https://builds.dotnet.microsoft.com/dotnet/scripts/v1/dotnet-install.sh");
- public static readonly Uri DotNetInstallScript = new Uri ("https://builds.dotnet.microsoft.com/dotnet/scripts/v1/dotnet-install.sh");
- }
}
}
diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.Windows.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.Windows.cs
index 7c7a025398f..d59cfe637d6 100644
--- a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.Windows.cs
+++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.Windows.cs
@@ -13,10 +13,5 @@ partial class Defaults
partial class Paths
{
}
-
- partial class Urls
- {
- public static readonly Uri DotNetInstallScript = new Uri ("https://builds.dotnet.microsoft.com/dotnet/scripts/v1/dotnet-install.ps1");
- }
}
}
diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs
index b4d402c053c..40712980b48 100644
--- a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs
+++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs
@@ -178,22 +178,6 @@ public static partial class Paths
public static string CoreClrAppRuntimeAndroidX86 => GetCachedPath (ref coreclrAppRuntimeAndroidX86, () => GetCoreClrAppRuntimePath (ctx, "x86"));
public static string CoreClrAppRuntimeAndroidX86_64 => GetCachedPath (ref coreclrAppRuntimeAndroidX86_64, () => GetCoreClrAppRuntimePath (ctx, "x64"));
- public static string MicrosoftNETWorkloadMonoPackageDir => Path.Combine (
- XAPackagesDir,
- $"microsoft.net.workload.mono.toolchain.{{0}}.manifest-{ctx.Properties.GetRequiredValue (KnownProperties.DotNetMonoManifestVersionBand)}",
- ctx.Properties.GetRequiredValue (KnownProperties.MicrosoftNETWorkloadMonoToolChainPackageVersion)
- );
-
- public static string MicrosoftNETWorkloadMonoToolChainDir => Path.Combine (MicrosoftNETWorkloadMonoPackageDir, "data");
-
- public static string MicrosoftNETWorkloadEmscriptenPackageDir => Path.Combine (
- XAPackagesDir,
- $"microsoft.net.workload.emscripten.{{0}}.manifest-{ctx.Properties.GetRequiredValue (KnownProperties.DotNetEmscriptenManifestVersionBand)}",
- ctx.Properties.GetRequiredValue (KnownProperties.MicrosoftNETWorkloadEmscriptenPackageVersion)
- );
-
- public static string MicrosoftNETWorkloadEmscriptenDir => Path.Combine (MicrosoftNETWorkloadEmscriptenPackageDir, "data");
-
public static string DotNetPreviewPath => ctx.Properties.GetRequiredValue (KnownProperties.DotNetPreviewPath);
public static string DotNetPreviewTool => Path.Combine (DotNetPreviewPath, "dotnet");
diff --git a/build-tools/xaprepare/xaprepare/Main.cs b/build-tools/xaprepare/xaprepare/Main.cs
index d9157457413..4a65478c8be 100644
--- a/build-tools/xaprepare/xaprepare/Main.cs
+++ b/build-tools/xaprepare/xaprepare/Main.cs
@@ -27,7 +27,6 @@ sealed class ParsedOptions
public string? Configuration { get; set; }
public bool AutoProvision { get; set; }
public bool AutoProvisionUsesSudo { get; set; }
- public string? LocalDotNetSdkArchive { get; set; }
}
public static int Main (string[] args)
@@ -98,7 +97,6 @@ static async Task Run (string[] args)
"",
{"auto-provision=", $"Automatically install software required by .NET for Android", v => parsedOptions.AutoProvision = ParseBoolean (v)},
{"auto-provision-uses-sudo=", $"Allow use of sudo(1) when provisioning", v => parsedOptions.AutoProvisionUsesSudo = ParseBoolean (v)},
- {"dotnet-sdk-archive=", "Path to a local .NET SDK archive (zip or tar.gz) to use instead of downloading from the internet.", v => parsedOptions.LocalDotNetSdkArchive = v?.Trim () },
"",
{"h|help", "Show this help message", v => parsedOptions.ShowHelp = true },
};
@@ -128,7 +126,6 @@ static async Task Run (string[] args)
Context.Instance.DebugFileExtension = parsedOptions.DebugFileExtension;
Context.Instance.AutoProvision = parsedOptions.AutoProvision;
Context.Instance.AutoProvisionUsesSudo = parsedOptions.AutoProvisionUsesSudo;
- Context.Instance.LocalDotNetSdkArchive = parsedOptions.LocalDotNetSdkArchive;
if (!String.IsNullOrEmpty (parsedOptions.Configuration))
Context.Instance.Configuration = parsedOptions.Configuration!;
diff --git a/build-tools/xaprepare/xaprepare/Scenarios/Scenario_AndroidTestDependencies.cs b/build-tools/xaprepare/xaprepare/Scenarios/Scenario_AndroidTestDependencies.cs
index ca0c311f2d2..3c2efee3c7d 100644
--- a/build-tools/xaprepare/xaprepare/Scenarios/Scenario_AndroidTestDependencies.cs
+++ b/build-tools/xaprepare/xaprepare/Scenarios/Scenario_AndroidTestDependencies.cs
@@ -15,8 +15,6 @@ protected Scenario_AndroidTestDependencies (string name, string description)
protected override void AddSteps (Context context)
{
- Steps.Add (new Step_InstallDotNetPreview ());
-
// disable installation of missing programs...
context.SetCondition (KnownConditions.AllowProgramInstallation, false);
diff --git a/build-tools/xaprepare/xaprepare/Scenarios/Scenario_Standard.cs b/build-tools/xaprepare/xaprepare/Scenarios/Scenario_Standard.cs
index 862c752e07a..06cfc3086df 100644
--- a/build-tools/xaprepare/xaprepare/Scenarios/Scenario_Standard.cs
+++ b/build-tools/xaprepare/xaprepare/Scenarios/Scenario_Standard.cs
@@ -18,7 +18,6 @@ protected override void AddSteps (Context context)
if (context == null)
throw new ArgumentNullException (nameof (context));
- Steps.Add (new Step_InstallDotNetPreview ());
Steps.Add (new Step_GenerateFiles (atBuildStart: true));
Steps.Add (new Step_GenerateCGManifest ());
}
diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs b/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs
deleted file mode 100644
index 7d53a9b5330..00000000000
--- a/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs
+++ /dev/null
@@ -1,220 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Threading.Tasks;
-
-namespace Xamarin.Android.Prepare
-{
- class Step_InstallDotNetPreview : StepWithDownloadProgress, IBuildInventoryItem
- {
- public string BuildToolName => "dotnet-preview";
- public string BuildToolVersion => Context.Instance.Properties.GetRequiredValue (KnownProperties.MicrosoftDotnetSdkInternalPackageVersion);
-
- public Step_InstallDotNetPreview ()
- : base ("Install required .NET Preview SDK locally")
- { }
-
- protected override async Task Execute (Context context)
- {
- var dotnetPath = Configurables.Paths.DotNetPreviewPath;
- dotnetPath = dotnetPath.TrimEnd (new char [] { Path.DirectorySeparatorChar });
-
- // Check if a local SDK archive was specified
- if (!String.IsNullOrEmpty (context.LocalDotNetSdkArchive)) {
- if (!await InstallDotNetFromLocalArchiveAsync (context, dotnetPath, context.LocalDotNetSdkArchive!)) {
- Log.ErrorLine ($"Installation of dotnet SDK from local archive '{context.LocalDotNetSdkArchive}' failed.");
- return false;
- }
- } else if (!await InstallDotNetAsync (context, dotnetPath, BuildToolVersion, useCachedInstallScript: true) &&
- !await InstallDotNetAsync (context, dotnetPath, BuildToolVersion, useCachedInstallScript: false)) {
- Log.ErrorLine ($"Installation of dotnet SDK '{BuildToolVersion}' failed.");
- return false;
- }
-
- AddToInventory ();
-
- // Delete all relevant NuGet package install directories, as we could possibly be using a new runtime commit with a previously installed version (6.0.0)
- var runtimeDirs = Directory.GetDirectories (Configurables.Paths.XAPackagesDir, "microsoft.netcore.app.runtime.mono.android*");
- var packageDirsToRemove = new List (runtimeDirs);
- packageDirsToRemove.Add (Configurables.Paths.MicrosoftNETWorkloadMonoPackageDir);
- foreach (var packageDir in packageDirsToRemove) {
- if (Directory.Exists (packageDir)) {
- Utilities.DeleteDirectory (packageDir);
- }
- }
-
- // Install runtime packs associated with the SDK previously installed.
- var packageDownloadProj = Path.Combine (BuildPaths.XamarinAndroidSourceRoot, "build-tools", "xaprepare", "xaprepare", "package-download.proj");
- var logPathBase = Path.Combine (Configurables.Paths.BuildBinDir, $"msbuild-{context.BuildTimeStamp}-download-runtime-packs");
-
- const int maxAttempts = 3;
- const int initialBackoffDelayMilliseconds = 2000;
- bool restoreSucceeded = false;
- for (int attempt = 1; attempt <= maxAttempts; attempt++) {
- var logPath = $"{logPathBase}-attempt{attempt}.binlog";
- var runner = new ProcessRunner (Configurables.Paths.DotNetPreviewTool, "restore",
- packageDownloadProj,
- "--configfile", Path.Combine (BuildPaths.XamarinAndroidSourceRoot, "NuGet.config"),
- $"-bl:{logPath}",
- "--verbosity", "normal"
- ) {
- EchoStandardOutput = true,
- EchoStandardError = true,
- };
- if (runner.Run ()) {
- restoreSucceeded = true;
- break;
- }
- if (attempt < maxAttempts) {
- Log.WarningLine ($"Failed to restore runtime packs (attempt {attempt}/{maxAttempts}), retrying...");
- var delayMilliseconds = initialBackoffDelayMilliseconds * (1 << (attempt - 1));
- await Task.Delay (delayMilliseconds);
- }
- }
- if (!restoreSucceeded) {
- Log.ErrorLine ($"Failed to restore runtime packs using '{packageDownloadProj}' after {maxAttempts} attempts.");
- return false;
- }
-
- var sdk_manifests = Path.Combine (dotnetPath, "sdk-manifests");
-
- // Copy the WorkloadManifest.* files from the latest Microsoft.NET.Workload.* listed in package-download.proj
- var dotnets = new [] { "net6", "net7", "net8", "net9", "net10", "current" };
- foreach (var dotnet in dotnets) {
- var destination = Path.Combine (sdk_manifests,
- context.Properties.GetRequiredValue (KnownProperties.DotNetMonoManifestVersionBand),
- $"microsoft.net.workload.mono.toolchain.{dotnet}",
- context.Properties.GetRequiredValue (KnownProperties.MicrosoftNETWorkloadMonoToolChainPackageVersion));
- Utilities.DeleteDirectory (destination, recurse: true);
- foreach (var file in Directory.GetFiles (string.Format (Configurables.Paths.MicrosoftNETWorkloadMonoToolChainDir, dotnet), "*")) {
- Utilities.CopyFileToDir (file, destination);
- }
- destination = Path.Combine (sdk_manifests,
- context.Properties.GetRequiredValue (KnownProperties.DotNetEmscriptenManifestVersionBand),
- $"microsoft.net.workload.emscripten.{dotnet}",
- context.Properties.GetRequiredValue (KnownProperties.MicrosoftNETWorkloadEmscriptenPackageVersion));
- Utilities.DeleteDirectory (destination, recurse: true);
- foreach (var file in Directory.GetFiles (string.Format (Configurables.Paths.MicrosoftNETWorkloadEmscriptenDir, dotnet), "*")) {
- Utilities.CopyFileToDir (file, destination);
- }
- }
-
- return true;
- }
-
- async Task DownloadDotNetInstallScript (Context context, string dotnetScriptPath, Uri dotnetScriptUrl, bool useCachedInstallScript)
- {
- string tempDotnetScriptPath = dotnetScriptPath + "-tmp";
- Utilities.DeleteFile (tempDotnetScriptPath);
-
- Log.StatusLine ("Downloading dotnet-install script...");
-
- if (useCachedInstallScript && File.Exists (dotnetScriptPath)) {
- Log.StatusLine ($"Using cached installation script found in '{dotnetScriptPath}'");
- return true;
- }
- Utilities.DeleteFile (dotnetScriptPath);
-
- Log.StatusLine ($" {context.Characters.Link} {dotnetScriptUrl}", ConsoleColor.White);
- await Utilities.Download (dotnetScriptUrl, tempDotnetScriptPath, DownloadStatus.Empty);
-
- if (File.Exists (tempDotnetScriptPath)) {
- Utilities.CopyFile (tempDotnetScriptPath, dotnetScriptPath);
- Utilities.DeleteFile (tempDotnetScriptPath);
- return true;
- }
-
- if (File.Exists (dotnetScriptPath)) {
- Log.WarningLine ($"Download of dotnet-install from '{dotnetScriptUrl}' failed");
- Log.StatusLine ($"Using cached installation script found in '{dotnetScriptPath}'");
- return true;
- } else {
- Log.ErrorLine ($"Download of dotnet-install from '{dotnetScriptUrl}' failed");
- return false;
- }
- }
-
- string[] GetInstallationScriptArgs (string version, string dotnetPath, string dotnetScriptPath, bool runtimeOnly)
- {
- List args;
- if (Context.IsWindows) {
- args = new List {
- "-NoProfile", "-ExecutionPolicy", "unrestricted", "-file", dotnetScriptPath,
- "-Version", version, "-InstallDir", dotnetPath, "-Verbose"
- };
- if (runtimeOnly) {
- args.AddRange (new string [] { "-Runtime", "dotnet" });
- }
- return args.ToArray ();
- }
-
- args = new List {
- dotnetScriptPath, "--version", version, "--install-dir", dotnetPath, "--verbose"
- };
-
- if (runtimeOnly) {
- args.AddRange (new string [] { "--runtime", "dotnet" });
- }
- return args.ToArray ();
- }
-
- async Task InstallDotNetFromLocalArchiveAsync (Context context, string dotnetPath, string archivePath)
- {
- if (!File.Exists (archivePath)) {
- Log.ErrorLine ($"Local .NET SDK archive not found: '{archivePath}'");
- return false;
- }
-
- Log.StatusLine ($"Installing .NET SDK from local archive: {archivePath}");
-
- // Always delete the bin/$(Configuration)/dotnet/ directory
- Utilities.DeleteDirectory (dotnetPath);
-
- return await Utilities.Unpack (archivePath, dotnetPath);
- }
-
- // Standardize on dotnet/arcade's usage of the dotnet-install scripts:
- // invoke dotnet-install.{sh,ps1} directly with --version/--install-dir
- // rather than harvesting URLs and downloading/extracting the archive
- // ourselves. This matches Arcade's eng/common/tools.sh and our CI
- // (build-tools/automation/yaml-templates/use-dot-net.yaml), lets the
- // script perform its built-in SHA-512 verification of the archive, and
- // relies on the script's own "already installed" check for incremental
- // re-runs (no need to re-download when the requested version is present).
- async Task InstallDotNetAsync (Context context, string dotnetPath, string version, bool useCachedInstallScript, bool runtimeOnly = false)
- {
- string cacheDir = context.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory);
-
- Uri dotnetScriptUrl = Configurables.Urls.DotNetInstallScript;
- string scriptFileName = Path.GetFileName (dotnetScriptUrl.LocalPath);
- string cachedDotnetScriptPath = Path.Combine (cacheDir, scriptFileName);
- if (!await DownloadDotNetInstallScript (context, cachedDotnetScriptPath, dotnetScriptUrl, useCachedInstallScript)) {
- return false;
- }
-
- Directory.CreateDirectory (dotnetPath);
- string dotnetScriptPath = Path.Combine (dotnetPath, scriptFileName);
- Utilities.CopyFile (cachedDotnetScriptPath, dotnetScriptPath);
-
- var type = runtimeOnly ? "runtime" : "SDK";
- Log.StatusLine ($"Installing dotnet {type} '{version}'...");
-
- string scriptCommand = Context.IsWindows ? "powershell.exe" : "bash";
- string[] scriptArgs = GetInstallationScriptArgs (version, dotnetPath, dotnetScriptPath, runtimeOnly);
- return Utilities.RunCommand (scriptCommand, scriptArgs);
- }
-
- bool TestDotNetSdk (string dotnetTool)
- {
- return Utilities.RunCommand (dotnetTool, new string [] { "--version" });
- }
-
- public void AddToInventory ()
- {
- if (!string.IsNullOrEmpty (BuildToolName) && !string.IsNullOrEmpty (BuildToolVersion) && !Context.Instance.BuildToolsInventory.ContainsKey (BuildToolName)) {
- Context.Instance.BuildToolsInventory.Add (BuildToolName, BuildToolVersion);
- }
- }
-
- }
-}
diff --git a/build-tools/xaprepare/xaprepare/package-download.proj b/build-tools/xaprepare/xaprepare/package-download.proj
deleted file mode 100644
index dcf3c42420d..00000000000
--- a/build-tools/xaprepare/xaprepare/package-download.proj
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-
-
-
-
- netstandard2.0
- $(MicrosoftNETCoreAppRefPackageVersion)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/eng/install-dotnet.ps1 b/eng/install-dotnet.ps1
new file mode 100644
index 00000000000..6eaa2a4e44d
--- /dev/null
+++ b/eng/install-dotnet.ps1
@@ -0,0 +1,43 @@
+<#
+.SYNOPSIS
+ Provisions the .NET SDK into bin\$Configuration\dotnet\.
+
+.DESCRIPTION
+ The SDK version is read from eng\Versions.props (single source of truth
+ kept up to date by darc when Microsoft.NET.Sdk flows from dotnet/dotnet),
+ so global.json does not need a 'tools.dotnet' pin.
+#>
+[CmdletBinding(PositionalBinding=$false)]
+param(
+ [string][Alias('c')] $configuration = $(if ($env:CONFIGURATION) { $env:CONFIGURATION } else { 'Debug' })
+)
+
+$ErrorActionPreference = 'Stop'
+
+$scriptroot = Split-Path -Parent $MyInvocation.MyCommand.Path
+$repoRoot = (Resolve-Path (Join-Path $scriptroot '..')).Path
+
+$versionsProps = Join-Path $repoRoot 'eng\Versions.props'
+[xml] $versionsXml = Get-Content -LiteralPath $versionsProps
+$sdkVersion = $versionsXml.SelectSingleNode('//MicrosoftNETSdkPackageVersion').InnerText
+if ([string]::IsNullOrWhiteSpace($sdkVersion)) {
+ Write-Error "Could not read from $versionsProps"
+ exit 1
+}
+
+$installDir = Join-Path $repoRoot "bin\$configuration\dotnet"
+New-Item -ItemType Directory -Force -Path $installDir | Out-Null
+
+# Download Microsoft's official dotnet-install.ps1 (cached under $installDir
+# to avoid hitting the CDN on idempotent re-runs).
+$installScript = Join-Path $installDir 'dotnet-install.ps1'
+if (-not (Test-Path $installScript)) {
+ [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
+ Invoke-WebRequest -Uri 'https://builds.dotnet.microsoft.com/dotnet/scripts/v1/dotnet-install.ps1' -OutFile $installScript -UseBasicParsing
+}
+
+Write-Host "Installing .NET SDK $sdkVersion into $installDir"
+& $installScript -Version $sdkVersion -InstallDir $installDir -NoPath
+if ($LASTEXITCODE -ne 0) {
+ exit $LASTEXITCODE
+}
diff --git a/eng/install-dotnet.sh b/eng/install-dotnet.sh
new file mode 100644
index 00000000000..da3fe042a62
--- /dev/null
+++ b/eng/install-dotnet.sh
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+#
+# Provisions the .NET SDK into bin/$Configuration/dotnet/.
+#
+# The SDK version is read from eng/Versions.props (single source of truth
+# kept up to date by darc when Microsoft.NET.Sdk flows from dotnet/dotnet),
+# so global.json does not need a 'tools.dotnet' pin.
+#
+# Inputs (env vars):
+# CONFIGURATION - Debug (default) or Release; controls install path.
+#
+
+set -euo pipefail
+
+scriptroot="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+repo_root="$( cd -P "$scriptroot/.." && pwd )"
+
+configuration="${CONFIGURATION:-Debug}"
+
+versions_props="$repo_root/eng/Versions.props"
+sdk_version="$(sed -n 's|.*\([^<]*\).*|\1|p' "$versions_props" | head -n 1)"
+if [[ -z "$sdk_version" ]]; then
+ echo "error: could not read from $versions_props" >&2
+ exit 1
+fi
+
+install_dir="$repo_root/bin/$configuration/dotnet"
+mkdir -p "$install_dir"
+
+# Download Microsoft's official dotnet-install.sh (cached under
+# $install_dir to avoid hitting the CDN on idempotent re-runs). Invoke
+# via `bash` so the executable bit isn't needed (Windows clones often
+# strip it).
+install_script="$install_dir/dotnet-install.sh"
+if [[ ! -f "$install_script" ]]; then
+ curl -fsSL "https://builds.dotnet.microsoft.com/dotnet/scripts/v1/dotnet-install.sh" -o "$install_script"
+fi
+
+echo "Installing .NET SDK $sdk_version into $install_dir"
+bash "$install_script" --version "$sdk_version" --install-dir "$install_dir" --no-path
diff --git a/src/Xamarin.Installer.Build.Tasks/README.md b/src/Xamarin.Installer.Build.Tasks/README.md
index 7ed432c4cfe..cfed21754f3 100644
--- a/src/Xamarin.Installer.Build.Tasks/README.md
+++ b/src/Xamarin.Installer.Build.Tasks/README.md
@@ -15,7 +15,9 @@ _without_ building dotnet/android, though it does require a dotnet/android check
* Clone or navigate to your `dotnet/android` checkout, and install the sandboxed .NET preview:
```
- dotnet run --project build-tools/xaprepare/xaprepare/xaprepare.csproj -- -s AndroidTestDependencies
+ bash ./eng/install-dotnet.sh # macOS / Linux
+ pwsh ./eng/install-dotnet.ps1 # Windows
+ dotnet build src/workloads/workloads.csproj
```
* Download the `nuget-unsigned` build artifact from the [latest build][0] from the branch you want to test, and move it to the `bin/BuildDebug` folder.
diff --git a/src/workloads/workloads.csproj b/src/workloads/workloads.csproj
new file mode 100644
index 00000000000..a0043194470
--- /dev/null
+++ b/src/workloads/workloads.csproj
@@ -0,0 +1,131 @@
+
+
+
+
+ $(DotNetStableTargetFramework)
+ $(MicrosoftNETCoreAppRefPackageVersion)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_DotNetSdk>$(DotNetPreviewPath.TrimEnd('\').TrimEnd('/'))
+ <_SdkManifests>$(_DotNetSdk)\sdk-manifests
+
+
+
+
+
+
+ <_MonoManifestSource Include="$(XAPackagesDir)\microsoft.net.workload.mono.toolchain.net6.manifest-$(DotNetMonoManifestVersionBand)\$(MicrosoftNETWorkloadMonoToolChainPackageVersion)\data\*">
+ $(_SdkManifests)\$(DotNetMonoManifestVersionBand)\microsoft.net.workload.mono.toolchain.net6\$(MicrosoftNETWorkloadMonoToolChainPackageVersion)
+
+ <_MonoManifestSource Include="$(XAPackagesDir)\microsoft.net.workload.mono.toolchain.net7.manifest-$(DotNetMonoManifestVersionBand)\$(MicrosoftNETWorkloadMonoToolChainPackageVersion)\data\*">
+ $(_SdkManifests)\$(DotNetMonoManifestVersionBand)\microsoft.net.workload.mono.toolchain.net7\$(MicrosoftNETWorkloadMonoToolChainPackageVersion)
+
+ <_MonoManifestSource Include="$(XAPackagesDir)\microsoft.net.workload.mono.toolchain.net8.manifest-$(DotNetMonoManifestVersionBand)\$(MicrosoftNETWorkloadMonoToolChainPackageVersion)\data\*">
+ $(_SdkManifests)\$(DotNetMonoManifestVersionBand)\microsoft.net.workload.mono.toolchain.net8\$(MicrosoftNETWorkloadMonoToolChainPackageVersion)
+
+ <_MonoManifestSource Include="$(XAPackagesDir)\microsoft.net.workload.mono.toolchain.net9.manifest-$(DotNetMonoManifestVersionBand)\$(MicrosoftNETWorkloadMonoToolChainPackageVersion)\data\*">
+ $(_SdkManifests)\$(DotNetMonoManifestVersionBand)\microsoft.net.workload.mono.toolchain.net9\$(MicrosoftNETWorkloadMonoToolChainPackageVersion)
+
+ <_MonoManifestSource Include="$(XAPackagesDir)\microsoft.net.workload.mono.toolchain.net10.manifest-$(DotNetMonoManifestVersionBand)\$(MicrosoftNETWorkloadMonoToolChainPackageVersion)\data\*">
+ $(_SdkManifests)\$(DotNetMonoManifestVersionBand)\microsoft.net.workload.mono.toolchain.net10\$(MicrosoftNETWorkloadMonoToolChainPackageVersion)
+
+ <_MonoManifestSource Include="$(XAPackagesDir)\microsoft.net.workload.mono.toolchain.current.manifest-$(DotNetMonoManifestVersionBand)\$(MicrosoftNETWorkloadMonoToolChainPackageVersion)\data\*">
+ $(_SdkManifests)\$(DotNetMonoManifestVersionBand)\microsoft.net.workload.mono.toolchain.current\$(MicrosoftNETWorkloadMonoToolChainPackageVersion)
+
+
+
+ <_EmscriptenManifestSource Include="$(XAPackagesDir)\microsoft.net.workload.emscripten.net6.manifest-$(DotNetEmscriptenManifestVersionBand)\$(MicrosoftNETWorkloadEmscriptenPackageVersion)\data\*">
+ $(_SdkManifests)\$(DotNetEmscriptenManifestVersionBand)\microsoft.net.workload.emscripten.net6\$(MicrosoftNETWorkloadEmscriptenPackageVersion)
+
+ <_EmscriptenManifestSource Include="$(XAPackagesDir)\microsoft.net.workload.emscripten.net7.manifest-$(DotNetEmscriptenManifestVersionBand)\$(MicrosoftNETWorkloadEmscriptenPackageVersion)\data\*">
+ $(_SdkManifests)\$(DotNetEmscriptenManifestVersionBand)\microsoft.net.workload.emscripten.net7\$(MicrosoftNETWorkloadEmscriptenPackageVersion)
+
+ <_EmscriptenManifestSource Include="$(XAPackagesDir)\microsoft.net.workload.emscripten.net8.manifest-$(DotNetEmscriptenManifestVersionBand)\$(MicrosoftNETWorkloadEmscriptenPackageVersion)\data\*">
+ $(_SdkManifests)\$(DotNetEmscriptenManifestVersionBand)\microsoft.net.workload.emscripten.net8\$(MicrosoftNETWorkloadEmscriptenPackageVersion)
+
+ <_EmscriptenManifestSource Include="$(XAPackagesDir)\microsoft.net.workload.emscripten.net9.manifest-$(DotNetEmscriptenManifestVersionBand)\$(MicrosoftNETWorkloadEmscriptenPackageVersion)\data\*">
+ $(_SdkManifests)\$(DotNetEmscriptenManifestVersionBand)\microsoft.net.workload.emscripten.net9\$(MicrosoftNETWorkloadEmscriptenPackageVersion)
+
+ <_EmscriptenManifestSource Include="$(XAPackagesDir)\microsoft.net.workload.emscripten.net10.manifest-$(DotNetEmscriptenManifestVersionBand)\$(MicrosoftNETWorkloadEmscriptenPackageVersion)\data\*">
+ $(_SdkManifests)\$(DotNetEmscriptenManifestVersionBand)\microsoft.net.workload.emscripten.net10\$(MicrosoftNETWorkloadEmscriptenPackageVersion)
+
+ <_EmscriptenManifestSource Include="$(XAPackagesDir)\microsoft.net.workload.emscripten.current.manifest-$(DotNetEmscriptenManifestVersionBand)\$(MicrosoftNETWorkloadEmscriptenPackageVersion)\data\*">
+ $(_SdkManifests)\$(DotNetEmscriptenManifestVersionBand)\microsoft.net.workload.emscripten.current\$(MicrosoftNETWorkloadEmscriptenPackageVersion)
+
+
+
+
+
+
+
+