Skip to content

Commit

Permalink
[One .NET] dotnet workload install android or android-aot (#6045)
Browse files Browse the repository at this point in the history
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

Shorten this to be:

	dotnet workload install android

We can also create a new workload that extends `android`, and
includes AOT support:

	dotnet workload install android-aot

To test this behavior on our CI, I reworked the `ExtractWorkloadPacks`
MSBuild target to run `dotnet workload install` commands.  This should
give us more confidence that our workload can be installed -- and that
our MSBuild tests will consume the installed workload.

Other changes:

  * Added our `Microsoft.Android.Runtime.*` packs to
    `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`
  
  * Add `setup-test-environment.yaml` to another build phase
  • Loading branch information
jonathanpeppers committed Jul 6, 2021
1 parent 7282da9 commit 600e993
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 38 deletions.
20 changes: 6 additions & 14 deletions build-tools/automation/azure-pipelines.yaml
Expand Up @@ -1291,20 +1291,13 @@ stages:
workspace:
clean: all
steps:
- checkout: self
submodules: recursive
- template: yaml-templates/setup-test-environment.yaml
parameters:
xaSourcePath: $(System.DefaultWorkingDirectory)/xamarin-android

- checkout: release_scripts
clean: true

- template: yaml-templates/use-dot-net.yaml
parameters:
remove_dotnet: true

- template: yaml-templates/use-dot-net.yaml
parameters:
version: $(DotNetCoreVersion)

- task: DownloadPipelineArtifact@2
inputs:
${{ if eq(variables['MicroBuildSignType'], 'Real') }}:
Expand Down Expand Up @@ -1397,10 +1390,9 @@ stages:
- ${{ if eq(variables['MicroBuildSignType'], 'Real') }}:
- group: Publish-Build-Assets
steps:
- checkout: self
submodules: recursive

- template: yaml-templates/use-dot-net.yaml
- template: yaml-templates/setup-test-environment.yaml
parameters:
configuration: $(XA.Build.Configuration)

- task: DownloadPipelineArtifact@2
inputs:
Expand Down
44 changes: 22 additions & 22 deletions build-tools/create-packs/Directory.Build.targets
Expand Up @@ -75,12 +75,6 @@
DependsOnTargets="DeleteExtractedWorkloadPacks" >
<ItemGroup>
<_WLManifest Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.NET.Sdk.Android.Manifest-*.nupkg" />
<_WLPacks Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.Android.Sdk.$(HostOS).*.nupkg" />
<_WLPacks Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.Android.Sdk.BundleTool.*.nupkg" />
<_WLPacks Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.Android.Ref.*.nupkg" />
<_WLTemplates Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.Android.Templates.*.nupkg" />
<!-- Runtime packs are not yet supported by workloads -->
<!-- <_WLPacks Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.Android.Runtime.*.nupkg" /> -->
</ItemGroup>
<PropertyGroup>
<_WLPackVersion>@(_WLManifest->'%(Filename)'->Replace('Microsoft.NET.Sdk.Android.Manifest-$(DotNetPreviewVersionBand).', ''))</_WLPackVersion>
Expand All @@ -97,24 +91,30 @@
</ItemGroup>
<Move SourceFiles="@(_WLExtractedFiles)" DestinationFolder="$(_SdkManifestsFolder)microsoft.net.sdk.android" />
<RemoveDir Directories="$(_SdkManifestsFolder)temp\" />
<Unzip
SourceFiles="@(_WLPacks)"
DestinationFolder="$(DotNetPreviewPath)packs\$([System.String]::Copy('%(_WLPacks.Filename)').Replace('.$(_WLPackVersion)', ''))\$(_WLPackVersion)"
/>
<MakeDir Directories="$(DotNetPreviewPath)template-packs" />
<!-- TODO: Workaround Linux casing issue and copy template packs to lowercase destination -->
<Copy SourceFiles="@(_WLTemplates)" DestinationFiles="@(_WLTemplates->'%(Filename)%(Extension)'->ToLower()->'$(DotNetPreviewPath)template-packs\%(Identity)')" />
<ItemGroup>
<_UnixExecutables Include="$(DotNetPreviewPath)packs\Microsoft.Android.Sdk.*\*\tools\$(HostOS)\**\*.*" />
<_FilesToTouch Include="$(DotNetPreviewPath)sdk-manifests\$(DotNetPreviewVersionBand)\microsoft.net.sdk.android\**" />
<_FilesToTouch Include="$(DotNetPreviewPath)packs\$([System.String]::Copy('%(_WLPacks.Filename)').Replace('.$(_WLPackVersion)', ''))\$(_WLPackVersion)\**" />
</ItemGroup>

<!-- dotnet workload install android-aot -->
<PropertyGroup>
<_TempDirectory>$(DotNetPreviewPath)..\.xa-workload-temp-$([System.IO.Path]::GetRandomFileName())</_TempDirectory>
<_NuGetConfig>$(_TempDirectory)\NuGet.config</_NuGetConfig>
<_NuGetContent>
<![CDATA[
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="local" value="$(OutputPath)" />
<add key="dotnet6" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
</packageSources>
</configuration>
]]>
</_NuGetContent>
</PropertyGroup>
<WriteLinesToFile File="$(_NuGetConfig)" Lines="$(_NuGetContent)" Overwrite="true" />
<Exec
Condition=" '$(HostOS)' == 'Darwin' or '$(HostOS)' == 'Linux' "
Command="chmod +x &quot;%(_UnixExecutables.Identity)&quot;"
WorkingDirectory="$(_TempDirectory)"
Command="&quot;$(DotNetPreviewTool)&quot; workload install android-aot --skip-manifest-update --verbosity diag --temp-dir &quot;$(_TempDirectory)&quot;"
/>
<!-- Some files had timestamps in the future -->
<Touch Files="@(_FilesToTouch)" />
<RemoveDir Directories="$(_TempDirectory)" />
</Target>

<Target Name="DeleteExtractedWorkloadPacks" >
Expand Down
Expand Up @@ -68,6 +68,12 @@ protected override async Task<bool> Execute (Context context)
}
}

// Delete the metadata folder, which contains old workload data
var metadataPath = Path.Combine (dotnetPath, "metadata");
if (Directory.Exists (metadataPath)) {
Utilities.DeleteDirectory (metadataPath);
}

if (File.Exists (dotnetTool)) {
if (!TestDotNetSdk (dotnetTool)) {
Log.WarningLine ($"Attempt to run `dotnet --version` failed, reinstalling the SDK.");
Expand Down
@@ -1,15 +1,23 @@
{
"version": "@WORKLOAD_VERSION@",
"workloads": {
"microsoft-android-sdk-full": {
"description": "Android SDK",
"android": {
"description": "Microsoft Android SDK for .NET",
"packs": [
"Microsoft.Android.Sdk",
"Microsoft.Android.Sdk.BundleTool",
"Microsoft.Android.Ref",
"Microsoft.Android.Runtime.android-arm",
"Microsoft.Android.Runtime.android-arm64",
"Microsoft.Android.Runtime.android-x86",
"Microsoft.Android.Runtime.android-x64",
"Microsoft.Android.Templates"
],
"extends" : [ "microsoft-net-runtime-android" ]
},
"android-aot": {
"description": "Microsoft Android SDK for .NET with AOT support",
"extends" : [ "android", "microsoft-net-runtime-android-aot" ]
}
},
"packs": {
Expand All @@ -32,6 +40,22 @@
"kind": "framework",
"version": "@WORKLOAD_VERSION@"
},
"Microsoft.Android.Runtime.android-arm": {
"kind": "framework",
"version": "@WORKLOAD_VERSION@"
},
"Microsoft.Android.Runtime.android-arm64": {
"kind": "framework",
"version": "@WORKLOAD_VERSION@"
},
"Microsoft.Android.Runtime.android-x86": {
"kind": "framework",
"version": "@WORKLOAD_VERSION@"
},
"Microsoft.Android.Runtime.android-x64": {
"kind": "framework",
"version": "@WORKLOAD_VERSION@"
},
"Microsoft.Android.Templates": {
"kind": "template",
"version": "@WORKLOAD_VERSION@"
Expand Down

0 comments on commit 600e993

Please sign in to comment.