Skip to content

Commit c2ab215

Browse files
[One .NET] dotnet workload install android or android-full
Context: https://github.com/dotnet/maui/tree/ef4518bf502ffa6760625c4cb53fa0cb015bc6d1/src/Workload#net-maui-workload-ids Right now to install the Android workload you would run: dotnet workload install microsoft-android-sdk-full Let's shorten this to be: dotnet workload install android-full We can also create a smaller workload that excludes `bundletool` and AOT support to get a smaller install footprint: dotnet workload install android To test this behavior on our CI, I reworked the `ExtractWorkloadPacks` to run `dotnet workload install` commands. This should give us more confidence that our workload can be installed -- and our MSBuild tests will consume the installed workload. Other changes: * Added an `android-aot` workload, in case you want to install this support by itself. This is useful, also as a way to include a user-friendly description. * Added our `Microsoft.Android.Runtime.*` packs to the `WorkloadManifest.json`. This was mostly omitted by mistake; however, runtime packs aren't resolved either due to: dotnet/sdk#14044 * Call `setup-test-environment.yaml` in `dotnet_create_msi` job * Delete `dotnet/metadata` folder in `Step_InstallDotNetPreview`
1 parent 1bc67af commit c2ab215

File tree

4 files changed

+63
-29
lines changed

4 files changed

+63
-29
lines changed

build-tools/automation/azure-pipelines.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,10 +1397,9 @@ stages:
13971397
- ${{ if eq(variables['MicroBuildSignType'], 'Real') }}:
13981398
- group: Publish-Build-Assets
13991399
steps:
1400-
- checkout: self
1401-
submodules: recursive
1402-
1403-
- template: yaml-templates/use-dot-net.yaml
1400+
- template: yaml-templates/setup-test-environment.yaml
1401+
parameters:
1402+
configuration: $(XA.Build.Configuration)
14041403

14051404
- task: DownloadPipelineArtifact@2
14061405
inputs:

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

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,6 @@
7575
DependsOnTargets="DeleteExtractedWorkloadPacks" >
7676
<ItemGroup>
7777
<_WLManifest Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.NET.Sdk.Android.Manifest-*.nupkg" />
78-
<_WLPacks Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.Android.Sdk.$(HostOS).*.nupkg" />
79-
<_WLPacks Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.Android.Sdk.BundleTool.*.nupkg" />
80-
<_WLPacks Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.Android.Ref.*.nupkg" />
81-
<_WLTemplates Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.Android.Templates.*.nupkg" />
82-
<!-- Runtime packs are not yet supported by workloads -->
83-
<!-- <_WLPacks Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.Android.Runtime.*.nupkg" /> -->
8478
</ItemGroup>
8579
<PropertyGroup>
8680
<_WLPackVersion>@(_WLManifest->'%(Filename)'->Replace('Microsoft.NET.Sdk.Android.Manifest-$(DotNetPreviewVersionBand).', ''))</_WLPackVersion>
@@ -97,24 +91,29 @@
9791
</ItemGroup>
9892
<Move SourceFiles="@(_WLExtractedFiles)" DestinationFolder="$(_SdkManifestsFolder)microsoft.net.sdk.android" />
9993
<RemoveDir Directories="$(_SdkManifestsFolder)temp\" />
100-
<Unzip
101-
SourceFiles="@(_WLPacks)"
102-
DestinationFolder="$(DotNetPreviewPath)packs\$([System.String]::Copy('%(_WLPacks.Filename)').Replace('.$(_WLPackVersion)', ''))\$(_WLPackVersion)"
103-
/>
104-
<MakeDir Directories="$(DotNetPreviewPath)template-packs" />
105-
<!-- TODO: Workaround Linux casing issue and copy template packs to lowercase destination -->
106-
<Copy SourceFiles="@(_WLTemplates)" DestinationFiles="@(_WLTemplates->'%(Filename)%(Extension)'->ToLower()->'$(DotNetPreviewPath)template-packs\%(Identity)')" />
107-
<ItemGroup>
108-
<_UnixExecutables Include="$(DotNetPreviewPath)packs\Microsoft.Android.Sdk.*\*\tools\$(HostOS)\**\*.*" />
109-
<_FilesToTouch Include="$(DotNetPreviewPath)sdk-manifests\$(DotNetPreviewVersionBand)\microsoft.net.sdk.android\**" />
110-
<_FilesToTouch Include="$(DotNetPreviewPath)packs\$([System.String]::Copy('%(_WLPacks.Filename)').Replace('.$(_WLPackVersion)', ''))\$(_WLPackVersion)\**" />
111-
</ItemGroup>
94+
95+
<!-- dotnet workload install android-full -->
96+
<PropertyGroup>
97+
<_NuGetConfig>$(AndroidToolchainCacheDirectory)\NuGet.config</_NuGetConfig>
98+
<_NuGetContent>
99+
<![CDATA[
100+
<?xml version="1.0" encoding="utf-8"?>
101+
<configuration>
102+
<packageSources>
103+
<clear />
104+
<add key="local" value="$(OutputPath)" />
105+
<add key="dotnet6" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
106+
</packageSources>
107+
</configuration>
108+
]]>
109+
</_NuGetContent>
110+
</PropertyGroup>
111+
<WriteLinesToFile File="$(_NuGetConfig)" Lines="$(_NuGetContent)" Overwrite="true" />
112112
<Exec
113-
Condition=" '$(HostOS)' == 'Darwin' or '$(HostOS)' == 'Linux' "
114-
Command="chmod +x &quot;%(_UnixExecutables.Identity)&quot;"
113+
WorkingDirectory="$(AndroidToolchainCacheDirectory)"
114+
Command="&quot;$(DotNetPreviewTool)&quot; workload install android-full --skip-manifest-update --verbosity diag"
115115
/>
116-
<!-- Some files had timestamps in the future -->
117-
<Touch Files="@(_FilesToTouch)" />
116+
<Delete Files="$(_NuGetConfig)" />
118117
</Target>
119118

120119
<Target Name="DeleteExtractedWorkloadPacks" >

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ protected override async Task<bool> Execute (Context context)
6868
}
6969
}
7070

71+
// Delete the metadata folder, which contains old workload data
72+
var metadataPath = Path.Combine (dotnetPath, "metadata");
73+
if (Directory.Exists (metadataPath)) {
74+
Utilities.DeleteDirectory (metadataPath);
75+
}
76+
7177
if (File.Exists (dotnetTool)) {
7278
if (!TestDotNetSdk (dotnetTool)) {
7379
Log.WarningLine ($"Attempt to run `dotnet --version` failed, reinstalling the SDK.");

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

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
{
22
"version": "@WORKLOAD_VERSION@",
33
"workloads": {
4-
"microsoft-android-sdk-full": {
5-
"description": "Android SDK",
4+
"android": {
5+
"description": "Microsoft Android SDK for .NET",
66
"packs": [
77
"Microsoft.Android.Sdk",
8-
"Microsoft.Android.Sdk.BundleTool",
98
"Microsoft.Android.Ref",
9+
"Microsoft.Android.Runtime.android-arm",
10+
"Microsoft.Android.Runtime.android-arm64",
11+
"Microsoft.Android.Runtime.android-x86",
12+
"Microsoft.Android.Runtime.android-x64",
1013
"Microsoft.Android.Templates"
1114
],
1215
"extends" : [ "microsoft-net-runtime-android" ]
16+
},
17+
"android-full": {
18+
"description": "Microsoft Android SDK for .NET with AOT support",
19+
"packs": [
20+
"Microsoft.Android.Sdk.BundleTool"
21+
],
22+
"extends" : [ "android", "android-aot" ]
23+
},
24+
"android-aot": {
25+
"description": "Android AOT support",
26+
"extends" : [ "microsoft-net-runtime-android-aot" ]
1327
}
1428
},
1529
"packs": {
@@ -32,6 +46,22 @@
3246
"kind": "framework",
3347
"version": "@WORKLOAD_VERSION@"
3448
},
49+
"Microsoft.Android.Runtime.android-arm": {
50+
"kind": "framework",
51+
"version": "@WORKLOAD_VERSION@"
52+
},
53+
"Microsoft.Android.Runtime.android-arm64": {
54+
"kind": "framework",
55+
"version": "@WORKLOAD_VERSION@"
56+
},
57+
"Microsoft.Android.Runtime.android-x86": {
58+
"kind": "framework",
59+
"version": "@WORKLOAD_VERSION@"
60+
},
61+
"Microsoft.Android.Runtime.android-x64": {
62+
"kind": "framework",
63+
"version": "@WORKLOAD_VERSION@"
64+
},
3565
"Microsoft.Android.Templates": {
3666
"kind": "template",
3767
"version": "@WORKLOAD_VERSION@"

0 commit comments

Comments
 (0)