Skip to content

Commit

Permalink
[CI] Add nuget to msi conversion and VS insert stage (#6030)
Browse files Browse the repository at this point in the history
Context: xamarin/yaml-templates#117

A new CI job and stage have been added to facilitate the
Visual Studio installer insertion process.

The first job named "Convert NuGet to MSI" will convert signed
packages to `.msi` installers, and generate Visual Studio manifests
for the `.msi` installers.  The `.msi` files are signed and converted
back to `.nupkg` files for the Windows command line install scenario.
These packages are uploaded as pipeline artifacts named
`vsdrop-signed`, and  `vs-msi-nugets`.

The new `vs-workload.props` file contains version information and other
metadata used by the convert job to generate a Visual Studio manifest.
The `@(ShortNames)` item group is used to avoid path length issues
that can arise due to the way VS caches some components when building.
The `.msi` conversion tooling uses this to replace strings in the VS
component file names and IDs generated for our workload packs.
In some cases the semver label generated for our packs can be long,
so we replace the full semver version with a more predictable four
part version (30.0.100.x).

The new "VS Insertion" stage starts with a [manual validation task][0].
This task will pause execution and wait for someone to click a "Resume"
or "Reject" button that will appear on the pipeline UI.  This task is
configured to be rejected after waiting for two days, but it can be
manually re-ran any time after being rejected to trigger a VS insertion
for an older build.

To access the Reume or Reject button, go to the Pipelines page for
the commit to be approved, e.g.:

 1. https://github.com/xamarin/xamarin-android/commits/main

 2. Click the ✅ or ❌ for the commit of interest.  This displays an
    "All checks have passed" or "Some checks were not successful"
    overlay.

 3. Click the **Details** link for **Xamarin.Android** within the
    overlay shown by (2).

 4. At the bottom of the "runs" page, click the
    **View more details on Azure Pipelines** link.

When the manual validation task is approved, a VS Drop will be
created containing all .NET 6 `.msi` files.  This Drop URL can then
be used to update our component versions in Visual Studio.  This last
piece is currently manual as we will initially be introducing new
components, however we should be able to automate VS PR creation in
the future.

[0]: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/manual-validation?view=azure-devops&tabs=yaml
  • Loading branch information
pjcollins committed Jul 20, 2021
1 parent 21751b5 commit 505b8e9
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
20 changes: 20 additions & 0 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,18 @@ stages:
usePipelineArtifactTasks: true
condition: eq(variables['MicroBuildSignType'], 'Real')

# Check - "Xamarin.Android (.NET 6 Preview Installers Convert NuGet to MSI)"
- template: nuget-msi-convert/job/v1.yml@yaml
parameters:
yamlResourceName: yaml
dependsOn: signing
artifactName: nuget-signed
artifactPatterns: |
!*Darwin*
propsArtifactName: nuget-unsigned
signType: $(MicroBuildSignType)
condition: eq(variables['MicroBuildSignType'], 'Real')

# Check - "Xamarin.Android (.NET 6 Preview Installers Create .pkg)"
- job: dotnet_create_pkg
displayName: Create .pkg
Expand Down Expand Up @@ -1458,6 +1470,14 @@ stages:
solution: build-tools\Xamarin.Android.Tools.BootstrapTasks\Xamarin.Android.Tools.BootstrapTasks.csproj
artifactName: Build Results - .NET 6 Preview .msi

# .NET 6 VS Insertion Stage
# Check - "Xamarin.Android (VS Insertion - Wait For Approval)"
# Check - "Xamarin.Android (VS Insertion - Create VS Drop and Open PR)"
- template: vs-insertion/stage/v1.yml@yaml
parameters:
dependsOn: dotnet_installers
condition: eq(variables['MicroBuildSignType'], 'Real')

- stage: finalize_installers
displayName: Finalize Installers
dependsOn: mac_build
Expand Down
8 changes: 7 additions & 1 deletion build-tools/create-packs/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

<UsingTask TaskName="CreateFrameworkListFile" AssemblyFile="$(DotNetSharedFrameworkTaskFile)"/>
<UsingTask TaskName="GenerateBuildManifest" AssemblyFile="$(_MicrosoftDotNetBuildTasksFeedTaskDir)Microsoft.DotNet.Build.Tasks.Feed.dll" />
<UsingTask TaskName="Xamarin.Android.BuildTools.PrepTasks.ReplaceFileContents" AssemblyFile="$(PrepTasksAssembly)" />

<PropertyGroup>
<_MonoAndroidNETOutputDir>$(XAInstallPrefix)xbuild-frameworks\Microsoft.Android\net6.0\</_MonoAndroidNETOutputDir>
Expand Down Expand Up @@ -56,7 +57,7 @@
</Target>

<Target Name="CreateAllPacks"
DependsOnTargets="DeleteExtractedWorkloadPacks;_SetGlobalProperties">
DependsOnTargets="DeleteExtractedWorkloadPacks;_SetGlobalProperties;GetXAVersionInfo">
<RemoveDir Directories="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned" />
<Exec Command="dotnet pack @(_GlobalProperties, ' ') -p:AndroidRID=android-arm -p:AndroidABI=armeabi-v7a-net6 &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
<Exec Command="dotnet pack @(_GlobalProperties, ' ') -p:AndroidRID=android-arm64 -p:AndroidABI=arm64-v8a-net6 &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
Expand All @@ -69,6 +70,11 @@
<Exec Command="dotnet pack @(_GlobalProperties, ' ') &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Sdk.BundleTool.proj&quot;" />
<Exec Command="dotnet pack @(_GlobalProperties, ' ') &quot;$(MSBuildThisFileDirectory)Microsoft.NET.Sdk.Android.proj&quot;" />
<Exec Command="dotnet pack @(_GlobalProperties, ' ') &quot;$(XamarinAndroidSourcePath)src\Microsoft.Android.Templates\Microsoft.Android.Templates.csproj&quot;" />
<ReplaceFileContents
SourceFile="vs-workload.in.props"
DestinationFile="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\vs-workload.props"
Replacements="@PACK_VERSION_LONG@=$(AndroidPackVersionLong);@PACK_VERSION_SHORT@=$(AndroidMSIVersion);@WORKLOAD_VERSION@=$(AndroidMSIVersion)"
/>
</Target>

<Target Name="ExtractWorkloadPacks"
Expand Down
16 changes: 16 additions & 0 deletions build-tools/create-packs/vs-workload.in.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<TargetName>Microsoft.NET.Sdk.Android.Workload</TargetName>
</PropertyGroup>
<ItemGroup>
<!-- Shorten package names to avoid long path caching issues in Visual Studio -->
<ShortNames Include="@PACK_VERSION_LONG@">
<Replacement>@PACK_VERSION_SHORT@</Replacement>
</ShortNames>
<ComponentResources Include="android" Category=".NET" Title=".NET SDK for Android" Description=".NET SDK Workload for building Android applications."/>
<ComponentVersions Include="android" Version="@WORKLOAD_VERSION@" />
<ComponentResources Include="android-aot" Category=".NET" Title=".NET SDK for Android with AOT" Description=".NET SDK Workload for building Android applications with AOT support."/>
<ComponentVersions Include="android-aot" Version="@WORKLOAD_VERSION@" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"version": "@WORKLOAD_VERSION@",
"workloads": {
"android": {
"description": "Microsoft Android SDK for .NET",
"description": ".NET SDK Workload for building Android applications.",
"packs": [
"Microsoft.Android.Sdk",
"Microsoft.Android.Sdk.BundleTool",
Expand All @@ -16,7 +16,7 @@
"extends" : [ "microsoft-net-runtime-android" ]
},
"android-aot": {
"description": "Microsoft Android SDK for .NET with AOT support",
"description": ".NET SDK Workload for building Android applications with AOT support.",
"extends" : [ "android", "microsoft-net-runtime-android-aot" ]
}
},
Expand Down

0 comments on commit 505b8e9

Please sign in to comment.