Skip to content

Commit 952e67b

Browse files
authored
[build] Use dotnet/arcade dependency management tooling (#5731)
Context: https://github.com/dotnet/arcade/blob/ea609b8e036359934332480de9336d98fcbb3f91/Documentation/Darc.md The dotnet core engineering group has some dependency management tooling known as `darc` that we'd like to adopt. Integrating this tooling into the build system will make it easier to stay up to date with the latest .NET 6 SDK changes. Many dotnet repos use a [publishing workflow][0] that will push build artifact data to a central location known as the "Build Asset Registry". This data includes a "[Channel][1]" association, which is the key to dependency updating. Local updates and automatic update "Subscriptions" compare the version files in a given repo against the product versions available in the channel that you are interested in. We hope to be able to publish Xamarin SDK build information to this central registry in the near future, so that other products can take a dependency on us as needed (dotnet/maui for instance). The `darc` tool looks for four different files in a repo when adding a dependency or when checking for an update: * `eng/Version.Details.xml` * `eng/Versions.props` * `global.json` * `nuget.config` Both of the `Version*` files present in the `eng` folder are updated when a new dependency is available. To work with `darc` locally you will need to [install][2] the `darc` global tool, join the `arcade-contrib` GitHub team, and configure your auth settings. To add a new dependency, use the [`darc add-dependency`][3] command: darc add-dependency -n Microsoft.NetCore.App.Runtime.android-arm64 -t product -v 6.0.0-preview.2.21154.6 -r https://github.com/dotnet/runtime To update all dependencies, use the [`darc update-dependencies`][4] command: darc update-dependencies --channel ".NET 6" To configure automatic updates, use the [`darc add-subscription`][5] command to enroll a target repo/branch into updates from a particular channel: darc add-subscription --channel ".NET 6" --source-repo https://github.com/dotnet/installer --target-repo https://github.com/xamarin/xamarin-android --target-branch main --update-frequency everyWeek --standard-automerge Once a subscription is configured, [a pull request][6] will be created automatically by the dotnet Maestro bot when dependency updates are available. ~~~ This PR also contains a bump to .NET 6.0.100-preview.3.21168.18. Changes: dotnet/installer@19e22a7...823c1df The .NET 6 `.apkdesc` files have been updated accordingly. It seems that `System.Private.CoreLib.dll` grew in size, however reductions in native libraries/etc. results in an overall smaller package sizes. Simple XA: -"PackageSize": 2889606 +"PackageSize": 2877318 XF/XA: -"PackageSize": 8746124 +"PackageSize": 8733836 [0]: https://github.com/dotnet/arcade/blob/681511f2f63a3563494f1f27904b2842abef6b35/Documentation/CorePackages/Publishing.md#what-is-v3-publishing-how-is-it-different-from-v2 [1]: https://github.com/dotnet/arcade/blob/main/Documentation/BranchesChannelsAndSubscriptions.md#branches-channels-and-subscriptions-explained [2]: https://github.com/dotnet/arcade/blob/ea609b8e036359934332480de9336d98fcbb3f91/Documentation/Darc.md#setting-up-your-darc-client [3]: https://github.com/dotnet/arcade/blob/ea609b8e036359934332480de9336d98fcbb3f91/Documentation/Darc.md#add-dependency [4]: https://github.com/dotnet/arcade/blob/ea609b8e036359934332480de9336d98fcbb3f91/Documentation/Darc.md#update-dependencies [5]: https://github.com/dotnet/arcade/blob/ea609b8e036359934332480de9336d98fcbb3f91/Documentation/Darc.md#add-subscription [6]: #5744
1 parent a198ce4 commit 952e67b

File tree

20 files changed

+234
-117
lines changed

20 files changed

+234
-117
lines changed

Configuration.props

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<!--
44
Note: This file *must* be imported *after* `$(Configuration)` is set.
55
-->
6+
<Import Project="$(MSBuildThisFileDirectory)eng\Versions.props" />
67
<Import
78
Project="$(MSBuildThisFileDirectory)Build$(Configuration)\Configuration.Generated.props"
89
Condition="Exists('$(MSBuildThisFileDirectory)Build$(Configuration)\Configuration.Generated.props')"
@@ -74,14 +75,6 @@
7475
<AndroidNdkDirectory Condition=" '$(AndroidNdkDirectory)' == '' ">$(AndroidToolchainDirectory)\ndk</AndroidNdkDirectory>
7576
<DotNetPreviewPath Condition=" '$(DotNetPreviewPath)' == '' ">$(AndroidToolchainDirectory)\dotnet\</DotNetPreviewPath>
7677
<DotNetPreviewTool Condition=" '$(DotNetPreviewTool)' == '' ">$(DotNetPreviewPath)dotnet</DotNetPreviewTool>
77-
<!-- Version number from: https://github.com/dotnet/installer#installers-and-binaries -->
78-
<!-- Please update DotNetRuntimePacksVersion below accordingly -->
79-
<DotNetPreviewVersionBand Condition=" '$(DotNetPreviewVersionBand)' == '' ">6.0.100</DotNetPreviewVersionBand>
80-
<DotNetPreviewVersionFull Condition=" '$(DotNetPreviewVersionFull)' == '' ">$(DotNetPreviewVersionBand)-preview.3.21161.23</DotNetPreviewVersionFull>
81-
<!-- This version comes from the a file in the dotnet distribution: sdk/$(DotNetPreviewVersionFull)/dotnet.runtimeconfig.json (the `runtimeOptions/framework/version key`) -->
82-
<DotNetRuntimePacksVersion Condition=" '$(DotNetRuntimePacksVersion)' == '' ">6.0.0-preview.3.21159.16</DotNetRuntimePacksVersion>
83-
<ILLinkVersionBand Condition=" '$(ILLinkVersionBand)' == '' ">6.0.0</ILLinkVersionBand>
84-
<ILLinkVersionFull Condition=" '$(ILLinkVersionFull)' == '' ">$(ILLinkVersionBand)-alpha.1.21109.1</ILLinkVersionFull>
8578
<WixToolPath Condition=" '$(WixToolPath)' == '' ">$(AndroidToolchainDirectory)\wix\</WixToolPath>
8679
<AndroidCmakeVersion Condition=" '$(AndroidCmakeVersion)' == '' ">3.18.1</AndroidCmakeVersion>
8780
<AndroidCmakeUrlPrefix Condition=" '$(HostOS)' == 'Windows' And '$(AndroidCmakeUrlPrefix)' == '' ">7c386a739f915f5bd60051f2572c24782388e807.</AndroidCmakeUrlPrefix>

NuGet.config

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
<add key="dotnet-public" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" protocolVersion="3" />
77
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" protocolVersion="3" />
88
<add key="dotnet6" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
9-
10-
<!-- This is needed (currently) for the Xamarin.Android.Deploy.Installer dependency, getting the installer -->
11-
<!-- Android binary, to support delta APK install -->
12-
<add key="xamarin.android util" value="https://pkgs.dev.azure.com/xamarin/public/_packaging/Xamarin.Android/nuget/v3/index.json" />
9+
<!-- This is needed (currently) for the Xamarin.Android.Deploy.Installer dependency, getting the installer -->
10+
<!-- Android binary, to support delta APK install -->
11+
<add key="xamarin.android util" value="https://pkgs.dev.azure.com/xamarin/public/_packaging/Xamarin.Android/nuget/v3/index.json" />
1312
</packageSources>
13+
<disabledPackageSources />
1414
</configuration>

build-tools/create-dotnet-msi/create-dotnet-msi.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
Template="$(_WixTemplate)"
7575
DestinationFile="$(_WixFile)"
7676
DotNetPath="$(DotNetPreviewPath)"
77-
DotNetVersion="$(DotNetPreviewVersionFull)"
77+
DotNetVersion="$(MicrosoftDotnetSdkInternalPackageVersion)"
7878
MSIVersion="$(AndroidMSIVersion)"
7979
/>
8080
<ItemGroup>

build-tools/create-dotnet-pkg/create-dotnet-pkg.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<DotNetPayloadDir>$(PayloadDir)\usr\local\share\dotnet\</DotNetPayloadDir>
3939
</PropertyGroup>
4040
<ItemGroup>
41-
<_FilesToCopy Include="$(DotNetPreviewPath)\sdk\$(DotNetPreviewVersionFull)\EnableWorkloadResolver.sentinel" />
41+
<_FilesToCopy Include="$(DotNetPreviewPath)\sdk\$(MicrosoftDotnetSdkInternalPackageVersion)\EnableWorkloadResolver.sentinel" />
4242
<_FilesToCopy Include="$(DotNetPreviewPath)\sdk-manifests\$(DotNetPreviewVersionBand)\Microsoft.NET.Workload.Android\**\*" />
4343
<_FilesToCopy Include="$(DotNetPreviewPath)\packs\Microsoft.Android.Ref\**\*" />
4444
<_FilesToCopy Include="$(DotNetPreviewPath)\packs\Microsoft.Android.Sdk.osx-x64\**\*" />

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<PropertyGroup>
1414
<_MonoAndroidNETOutputDir>$(XAInstallPrefix)xbuild-frameworks\Microsoft.Android\netcoreapp3.1\</_MonoAndroidNETOutputDir>
15-
<_WorkloadResolverFlagFile>$(DotNetPreviewPath)sdk\$(DotNetPreviewVersionFull)\EnableWorkloadResolver.sentinel</_WorkloadResolverFlagFile>
15+
<_WorkloadResolverFlagFile>$(DotNetPreviewPath)sdk\$(MicrosoftDotnetSdkInternalPackageVersion)\EnableWorkloadResolver.sentinel</_WorkloadResolverFlagFile>
1616
</PropertyGroup>
1717

1818
<!-- LICENSE setup -->

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Linq;
55
using System.Text;
66
using System.Threading.Tasks;
7+
using System.Xml.Linq;
78

89
namespace Xamarin.Android.Prepare
910
{
@@ -358,6 +359,27 @@ public bool IsRunningOnHostedAzureAgent {
358359
}
359360
}
360361

362+
string _bundledPreviewRuntimePackVersion;
363+
public string BundledPreviewRuntimePackVersion {
364+
get {
365+
if (string.IsNullOrEmpty (_bundledPreviewRuntimePackVersion)) {
366+
var dotnetPath = Properties.GetRequiredValue (KnownProperties.DotNetPreviewPath);
367+
dotnetPath = dotnetPath.TrimEnd (new char [] { Path.DirectorySeparatorChar });
368+
var dotnetPreviewVersion = Properties.GetRequiredValue (KnownProperties.MicrosoftDotnetSdkInternalPackageVersion);
369+
var bundledVersionsPath = Path.Combine (dotnetPath, "sdk", dotnetPreviewVersion, "Microsoft.NETCoreSdk.BundledVersions.props");
370+
if (!File.Exists (bundledVersionsPath))
371+
throw new FileNotFoundException ("Could not find Microsoft.NETCoreSdk.BundledVersions.props.", bundledVersionsPath);
372+
373+
var version = XDocument.Load (bundledVersionsPath).Descendants ().FirstOrDefault (p => p.Name == "BundledNETCoreAppPackageVersion")?.Value ?? string.Empty;
374+
if (string.IsNullOrEmpty (version))
375+
throw new InvalidOperationException ($"Unable to locate $(BundledNETCoreAppPackageVersion) in {bundledVersionsPath}.");
376+
377+
_bundledPreviewRuntimePackVersion = version;
378+
}
379+
return _bundledPreviewRuntimePackVersion;
380+
}
381+
}
382+
361383
/// <summary>
362384
/// Do not install mingw-w64 with brew on MacOS, default false
363385
/// </summary>

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +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 DotNetPreviewVersionFull = "DotNetPreviewVersionFull";
25-
public const string DotNetRuntimePacksVersion = "DotNetRuntimePacksVersion";
24+
public const string MicrosoftDotnetSdkInternalPackageVersion = "MicrosoftDotnetSdkInternalPackageVersion";
2625
public const string EmulatorVersion = "EmulatorVersion";
2726
public const string EmulatorPkgRevision = "EmulatorPkgRevision";
2827
public const string HostOS = "HostOS";

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +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.DotNetPreviewVersionFull, StripQuotes ("@DotNetPreviewVersionFull@"));
29-
properties.Add (KnownProperties.DotNetRuntimePacksVersion, StripQuotes ("@DotNetRuntimePacksVersion@"));
28+
properties.Add (KnownProperties.MicrosoftDotnetSdkInternalPackageVersion, StripQuotes ("@MicrosoftDotnetSdkInternalPackageVersion@"));
3029
properties.Add (KnownProperties.EmulatorVersion, StripQuotes ("@EmulatorVersion@"));
3130
properties.Add (KnownProperties.EmulatorPkgRevision, StripQuotes ("@EmulatorPkgRevision@"));
3231
properties.Add (KnownProperties.HostOS, StripQuotes ("@HostOS@"));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ static string GetNetcoreAppRuntimePath (Context ctx, string androidTarget)
403403
return Path.Combine (
404404
XAPackagesDir,
405405
$"microsoft.netcore.app.runtime.android-{androidTarget}",
406-
ctx.Properties.GetRequiredValue (KnownProperties.DotNetRuntimePacksVersion),
406+
ctx.BundledPreviewRuntimePackVersion,
407407
"runtimes",
408408
$"android-{androidTarget}"
409409
);

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ protected override async Task<bool> Execute (Context context)
1717
{
1818
var dotnetPath = context.Properties.GetRequiredValue (KnownProperties.DotNetPreviewPath);
1919
dotnetPath = dotnetPath.TrimEnd (new char [] { Path.DirectorySeparatorChar });
20-
var dotnetPreviewVersion = context.Properties.GetRequiredValue (KnownProperties.DotNetPreviewVersionFull);
20+
var dotnetTool = Path.Combine (dotnetPath, "dotnet");
21+
var dotnetPreviewVersion = context.Properties.GetRequiredValue (KnownProperties.MicrosoftDotnetSdkInternalPackageVersion);
2122
var dotnetTestRuntimeVersion = Configurables.Defaults.DotNetTestRuntimeVersion;
2223

2324
// Delete any custom Microsoft.Android packs that may have been installed by test runs. Other ref/runtime packs will be ignored.
@@ -38,8 +39,8 @@ protected override async Task<bool> Execute (Context context)
3839
}
3940
}
4041

41-
if (Directory.Exists (dotnetPath)) {
42-
if (!TestDotNetSdk (dotnetPath)) {
42+
if (File.Exists (dotnetTool)) {
43+
if (!TestDotNetSdk (dotnetTool)) {
4344
Log.WarningLine ($"Attempt to run `dotnet --version` failed, reinstalling the SDK.");
4445
Utilities.DeleteDirectory (dotnetPath);
4546
}
@@ -55,7 +56,11 @@ protected override async Task<bool> Execute (Context context)
5556
return false;
5657
}
5758

58-
return true;
59+
// Install runtime packs associated with the SDK previously installed.
60+
var packageDownloadProj = Path.Combine (BuildPaths.XamarinAndroidSourceRoot, "build-tools", "xaprepare", "xaprepare", "package-download.proj");
61+
var logPath = Path.Combine (Configurables.Paths.BuildBinDir, $"msbuild-{context.BuildTimeStamp}-download-runtime-packs.binlog");
62+
return Utilities.RunCommand (dotnetTool, new string [] { "restore", $"-p:DotNetRuntimePacksVersion={context.BundledPreviewRuntimePackVersion}",
63+
ProcessRunner.QuoteArgument (packageDownloadProj), ProcessRunner.QuoteArgument ($"-bl:{logPath}") });
5964
}
6065

6166
async Task<bool> InstallDotNetAsync (Context context, string dotnetPath, string version, bool runtimeOnly = false)
@@ -122,9 +127,9 @@ async Task<bool> InstallDotNetAsync (Context context, string dotnetPath, string
122127
}
123128
}
124129

125-
bool TestDotNetSdk (string dotnetPath)
130+
bool TestDotNetSdk (string dotnetTool)
126131
{
127-
return Utilities.RunCommand (Path.Combine (dotnetPath, "dotnet"), new string [] { "--version" });
132+
return Utilities.RunCommand (dotnetTool, new string [] { "--version" });
128133
}
129134

130135
}

0 commit comments

Comments
 (0)