Bundle workload manifests as separate MSIs

This commit is contained in:
Daniel Plaisted 2021-11-02 23:39:27 -07:00
parent 9e8b04bbff
commit 082265dd3a
5 changed files with 78 additions and 268 deletions

View file

@ -1,84 +1,61 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<BundledManifests Include="Microsoft.NET.Sdk.Android.Manifest-6.0.100" Version="$(XamarinAndroidWorkloadManifestVersion)" WorkloadManifestId="Microsoft.NET.Sdk.Android" />
<BundledManifests Include="Microsoft.NET.Sdk.iOS.Manifest-6.0.100" Version="$(XamarinIOSWorkloadManifestVersion)" WorkloadManifestId="Microsoft.NET.Sdk.iOS" />
<BundledManifests Include="Microsoft.NET.Sdk.MacCatalyst.Manifest-6.0.100" Version="$(XamarinMacCatalystWorkloadManifestVersion)" WorkloadManifestId="Microsoft.NET.Sdk.MacCatalyst" />
<BundledManifests Include="Microsoft.NET.Sdk.macOS.Manifest-6.0.100" Version="$(XamarinMacOSWorkloadManifestVersion)" WorkloadManifestId="Microsoft.NET.Sdk.macOS" />
<BundledManifests Include="Microsoft.NET.Sdk.Maui.Manifest-6.0.100" Version="$(MauiWorkloadManifestVersion)" WorkloadManifestId="Microsoft.NET.Sdk.Maui" />
<BundledManifests Include="Microsoft.NET.Sdk.tvOS.Manifest-6.0.100" Version="$(XamarinTvOSWorkloadManifestVersion)" WorkloadManifestId="Microsoft.NET.Sdk.tvOS" />
<BundledManifests Include="Microsoft.NET.Workload.Mono.ToolChain.Manifest-6.0.100" Version="$(MonoWorkloadManifestVersion)" WorkloadManifestId="Microsoft.NET.Workload.Mono.ToolChain" />
<BundledManifests Include="Microsoft.NET.Workload.Emscripten.Manifest-6.0.100" Version="$(EmscriptenWorkloadManifestVersion)" WorkloadManifestId="Microsoft.NET.Workload.Emscripten" />
<BundledManifests Include="Microsoft.NET.Sdk.Android" FeatureBand="6.0.100" Version="$(XamarinAndroidWorkloadManifestVersion)" />
<BundledManifests Include="Microsoft.NET.Sdk.iOS" FeatureBand="6.0.100" Version="$(XamarinIOSWorkloadManifestVersion)" />
<BundledManifests Include="Microsoft.NET.Sdk.MacCatalyst" FeatureBand="6.0.100" Version="$(XamarinMacCatalystWorkloadManifestVersion)" />
<BundledManifests Include="Microsoft.NET.Sdk.macOS" FeatureBand="6.0.100" Version="$(XamarinMacOSWorkloadManifestVersion)" />
<BundledManifests Include="Microsoft.NET.Sdk.Maui" FeatureBand="6.0.100" Version="$(MauiWorkloadManifestVersion)" />
<BundledManifests Include="Microsoft.NET.Sdk.tvOS" FeatureBand="6.0.100" Version="$(XamarinTvOSWorkloadManifestVersion)" />
<BundledManifests Include="Microsoft.NET.Workload.Mono.ToolChain" FeatureBand="6.0.100" Version="$(MonoWorkloadManifestVersion)" />
<BundledManifests Include="Microsoft.NET.Workload.Emscripten" FeatureBand="6.0.100" Version="$(EmscriptenWorkloadManifestVersion)" />
</ItemGroup>
<!-- Restore workload manifests via PackageReference -->
<!-- Calculate NuGet package IDs for bundled manifests -->
<PropertyGroup>
<!-- TODO: Not exactly sure how this value should be calculated -->
<!--<MsiArchitectureForWorkloadManifests>$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant)</MsiArchitectureForWorkloadManifests>-->
<MsiArchitectureForWorkloadManifests>$(Architecture)</MsiArchitectureForWorkloadManifests>
</PropertyGroup>
<ItemGroup>
<BundledManifestsForPackageDownload Include="@(BundledManifests)" >
<Version>[%(Version)]</Version>
</BundledManifestsForPackageDownload>
<PackageDownload Include="@(BundledManifestsForPackageDownload)" />
</ItemGroup>
<ItemGroup>
<BundledManifests Update="@(BundledManifests)" >
<RestoredNupkgContentPath>$(NuGetPackageRoot)$([MSBuild]::ValueOrDefault('%(Identity)', '').ToLower())/$([MSBuild]::ValueOrDefault('%(Version)', '').ToLower())</RestoredNupkgContentPath>
<BundledManifests Update="@(BundledManifests)">
<NupkgId>%(Identity).Manifest-%(FeatureBand)</NupkgId>
<MsiNupkgId>%(Identity).Manifest-%(FeatureBand).Msi.$(MsiArchitectureForWorkloadManifests)</MsiNupkgId>
<RestoredNupkgContentPath>$(NuGetPackageRoot)$([MSBuild]::ValueOrDefault('%(NupkgId)', '').ToLower())/$([MSBuild]::ValueOrDefault('%(Version)', '').ToLower())</RestoredNupkgContentPath>
<RestoredMsiNupkgContentPath>$(NuGetPackageRoot)$([MSBuild]::ValueOrDefault('%(MsiNupkgId)', '').ToLower())/$([MSBuild]::ValueOrDefault('%(Version)', '').ToLower())</RestoredMsiNupkgContentPath>
<RestoredMsiPathInNupkg>%(RestoredMsiNupkgContentPath)/data/%(NupkgId).%(Version)-$(MsiArchitectureForWorkloadManifests).msi</RestoredMsiPathInNupkg>
</BundledManifests>
</ItemGroup>
<Target Name="LayoutManifests"
DependsOnTargets="LayoutManifestsForSDK;LayoutManifestsForMSI"/>
<!-- Restore workload manifests via PackageDownload -->
<ItemGroup>
<PackageDownload Include="@(BundledManifests->'%(NupkgId)')" >
<Version>[%(Version)]</Version>
</PackageDownload>
<Target Name="LayoutManifestsForSDK"
DependsOnTargets="SetupBundledComponents;GenerateManifestVersions">
<PackageDownload Include="@(BundledManifests->'%(MsiNupkgId)')" >
<Version>[%(Version)]</Version>
</PackageDownload>
</ItemGroup>
<Target Name="LayoutManifests"
DependsOnTargets="SetupBundledComponents">
<ItemGroup>
<ManifestContent Include="%(BundledManifests.RestoredNupkgContentPath)\data\*"
Condition="Exists('%(RestoredNupkgContentPath)\data')"
DestinationPath="$([MSBuild]::ValueOrDefault('%(Identity)', '').ToLower())"
RestoredNupkgContentPath="%(RestoredNupkgContentPath)"
WorkloadManifestId="%(Identity)"/>
<ManifestContent Include="%(BundledManifests.RestoredNupkgContentPath)\data\localize\*"
Condition="Exists('%(RestoredNupkgContentPath)\data\localize')"
DestinationPath="$([MSBuild]::ValueOrDefault('%(Identity)', '').ToLower())/localize"/>
</ItemGroup>
<Error Text="No workload manifest content found." Condition="'@(ManifestContent->Count())' == '0'" />
<Copy SourceFiles="@(ManifestContent)"
DestinationFolder="$(RedistLayoutPath)sdk-manifests/$(CliProductBandVersion)00/%(DestinationPath)"/>
</Target>
<Target Name="LayoutManifestsForMSI"
DependsOnTargets="SetupBundledComponents;GenerateManifestVersions"
Condition="$(ProductMonikerRid.StartsWith('win')) And '$(Architecture)' != 'arm'">
<Copy SourceFiles="@(ManifestContent)"
DestinationFolder="$(BaseOutputPath)$(Configuration)\sdk-manifests\sdk-manifests/$(CliProductBandVersion)00/%(DestinationPath)"/>
</Target>
<Target Name="GenerateManifestVersions">
<PropertyGroup>
<ManifestsMSIInstallerFile>$(ArtifactsNonShippingPackagesDir)dotnet-sdkmanifests-$(FullNugetVersion)-$(ProductMonikerRid)$(InstallerExtension)</ManifestsMSIInstallerFile>
<ManifestsDependencyKeyName>SDK_Manifests_$([MSBuild]::ValueOrDefault('$(Version)', '').Replace('-', '_'))</ManifestsDependencyKeyName>
<ManifestsBrandName>Microsoft .NET SDK Workload Manifests $(Version)</ManifestsBrandName>
<ManifestsLayoutPath>$(BaseOutputPath)$(Configuration)\sdk-manifests</ManifestsLayoutPath>
</PropertyGroup>
<GenerateMsiVersion BuildNumber="$(CombinedBuildNumberAndRevision)"
Major="$(VersionMajor)"
Minor="$(VersionMinor)"
Patch="$(VersionFeature)">
<Output TaskParameter="MsiVersion" PropertyName="ManifestMsiVersion" />
</GenerateMsiVersion>
<GenerateGuidFromName Name="$(ManifestsMSIInstallerFile)">
<Output TaskParameter="GeneratedGuid"
PropertyName="ManifestsInstallerUpgradeCode" />
</GenerateGuidFromName>
<ItemGroup>
<ManifestContent Include="%(BundledManifests.RestoredNupkgContentPath)\data\*"
Condition="Exists('%(RestoredNupkgContentPath)\data')"
DestinationPath="$([MSBuild]::ValueOrDefault('%(WorkloadManifestId)', '').ToLower())"
RestoredNupkgContentPath="%(RestoredNupkgContentPath)"
WorkloadManifestId="%(WorkloadManifestId)"/>
<ManifestContent Include="%(BundledManifests.RestoredNupkgContentPath)\data\localize\*"
Condition="Exists('%(RestoredNupkgContentPath)\data\localize')"
DestinationPath="$([MSBuild]::ValueOrDefault('%(WorkloadManifestId)', '').ToLower())/localize"/>
</ItemGroup>
<Error Text="No workload manifest content found." Condition="'@(ManifestContent->Count())' == '0'" />
</Target>
</Project>

View file

@ -283,49 +283,36 @@
</ItemGroup>
</Target>
<Target Name="GenerateManifestsMsi"
DependsOnTargets="GenerateLayout;AcquireWix;MsiTargetsSetupInputOutputs;SetSdkBrandingInfo"
Condition="$(ProductMonikerRid.StartsWith('win')) And '$(Architecture)' != 'arm'"
Inputs="@(BundledManifests);$(ManifestsGenerateMsiPowershellScript)"
Outputs="$(ManifestsMSIInstallerFile)">
<Target Name="GenerateWorkloadManifestsWxs">
<PropertyGroup>
<ManifestsGenerateMsiPowershellScript>$(MSBuildThisFileDirectory)packaging/windows/clisdk/generatemanifestsmsi.ps1</ManifestsGenerateMsiPowershellScript>
<WorkloadManifestsWxsPath>$(IntermediateOutputPath)WorkloadManifests.wxs</WorkloadManifestsWxsPath>
<WorkloadManifestsWxsContent>
<![CDATA[
<?xml version="1.0" encoding="utf-8"?>
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. -->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<PackageGroup Id="PG_WorkloadManifests">
@(BundledManifests->'<MsiPackage SourceFile="%(RestoredMsiPathInNupkg)">
<MsiProperty Name="DOTNETHOME" Value="[DOTNETHOME]" />
<MsiProperty Name="ALLOWMSIINSTALL" Value="True" />
</MsiPackage>', '
')
</PackageGroup>
</Fragment>
</Wix>
]]>
</WorkloadManifestsWxsContent>
</PropertyGroup>
<Exec Command="powershell -NoProfile -NoLogo $(ManifestsGenerateMsiPowershellScript) ^
'$(ManifestsLayoutPath)' ^
'$(ManifestsMSIInstallerFile)' ^
'$(WixRoot)' ^
'$(ManifestsBrandName)' ^
'$(ManifestMsiVersion)' ^
'$(ManifestMsiVersion)' ^
'$(FullNugetVersion)' ^
'$(ManifestsInstallerUpgradeCode)' ^
'$(ManifestsDependencyKeyName)' ^
'$(Architecture)' ^
-InformationAction Continue" />
<ItemGroup>
<ManifestsMsiWixSrcFiles Include="$(WixRoot)\provider.wixobj" />
<ManifestsMsiWixSrcFiles Include="$(WixRoot)\Manifests.wixobj" />
<ManifestsMsiWixSrcFiles Include="$(WixRoot)\dotnethome_x64.wixobj" />
<ManifestsMsiWixSrcFiles Include="$(WixRoot)\Manifest-install-files.wixobj" />
</ItemGroup>
<CreateLightCommandPackageDrop
LightCommandWorkingDir="$(LightCommandObjDir)"
OutputFolder="$(LightCommandPackagesDir)"
NoLogo="true"
Cultures="en-us"
InstallerFile="$(ArtifactsNonShippingPackagesDir)$(ManifestsMSIInstallerFile)"
WixExtensions="WixUIExtension;WixDependencyExtension;WixUtilExtension"
WixSrcFiles="@(ManifestsMsiWixSrcFiles)">
<Output TaskParameter="OutputFile" PropertyName="_LightCommandPackageNameOutput" />
</CreateLightCommandPackageDrop>
<WriteLinesToFile File="$(WorkloadManifestsWxsPath)"
Lines="$(WorkloadManifestsWxsContent)"
WriteOnlyWhenDifferent="true"
Overwrite="true" />
</Target>
<Target Name="GenerateSdkBundle"
DependsOnTargets="GenerateLayout;AcquireWix;MsiTargetsSetupInputOutputs;GenerateSdkMsi;SignSdkMsi;GenerateTemplatesMsis;GenerateManifestsMsi;SignTemplatesMsis"
DependsOnTargets="GenerateLayout;AcquireWix;MsiTargetsSetupInputOutputs;GenerateSdkMsi;SignSdkMsi;GenerateTemplatesMsis;GenerateWorkloadManifestsWxs;SignTemplatesMsis"
Condition=" '$(OS)' == 'Windows_NT' "
Inputs="$(SdkMSIInstallerFile);
$(DownloadedSharedFrameworkInstallerFile);
@ -344,6 +331,7 @@
</PropertyGroup>
<Exec Command="powershell -NoProfile -NoLogo $(SdkGenerateBundlePowershellScript) ^
'$(WorkloadManifestsWxsPath)' ^
'$(SdkMSIInstallerFile)' ^
'$(DownloadsFolder)$(DownloadedAspNetCoreSharedFxWixLibFileName)' ^
'$(DownloadsFolder)$(DownloadedSharedFrameworkInstallerFileName)' ^
@ -360,7 +348,6 @@
'$(DownloadsFolder)$(DownloadedWindowsDesktopTargetingPackInstallerFileName)' ^
'$(FinalizerExe)' ^
'$(LatestTemplateMsiInstallerFile)' ^
'$(ManifestsMsiInstallerFile)' ^
'$(CombinedFrameworkSdkHostMSIInstallerFile)' ^
'$(WixRoot)' ^
'$(SdkBrandName)' ^
@ -461,7 +448,7 @@
</Target>
<Target Name="GenerateManifestNupkg"
DependsOnTargets="GenerateLayout;GenerateManifestsMsi"
DependsOnTargets="GenerateLayout"
Condition=" '$(OS)' == 'Windows_NT' "
Inputs="$(ManifestsMSIInstallerFile);
$(ManifestInstallerNuspecFile);
@ -555,7 +542,6 @@
GenerateSdkMsi;
SignSdkMsi;
GenerateTemplatesMsis;
GenerateManifestsMsi;
SignTemplatesMsis;
GenerateSdkBundle;
SignSdkBundle;

View file

@ -194,10 +194,7 @@
<MsiProperty Name="DOTNETHOME" Value="[DOTNETHOME]" />
<MsiProperty Name="ALLOWMSIINSTALL" Value="True" />
</MsiPackage>
<MsiPackage SourceFile="$(var.ManifestsMsiSourcePath)">
<MsiProperty Name="DOTNETHOME" Value="[DOTNETHOME]" />
<MsiProperty Name="ALLOWMSIINSTALL" Value="True" />
</MsiPackage>
<PackageGroupRef Id="PG_WorkloadManifests" />
<MsiPackage SourceFile="$(var.CLISDKMsiSourcePath)">
<MsiProperty Name="DOTNETHOME" Value="[DOTNETHOME]" />
<MsiProperty Name="EXEFULLPATH" Value="[WixBundleOriginalSource]" />

View file

@ -2,6 +2,7 @@
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
param(
[Parameter(Mandatory=$true)][string]$WorkloadManifestWxsFile,
[Parameter(Mandatory=$true)][string]$CLISDKMSIFile,
[Parameter(Mandatory=$true)][string]$ASPNETRuntimeWixLibFile,
[Parameter(Mandatory=$true)][string]$SharedFxMSIFile,
@ -18,7 +19,6 @@ param(
[Parameter(Mandatory=$true)][string]$WindowsDesktopTargetingPackMSIFile,
[Parameter(Mandatory=$true)][string]$FinalizerExe,
[Parameter(Mandatory=$true)][string]$TemplatesMSIFile,
[Parameter(Mandatory=$true)][string]$ManifestsMSIFile,
[Parameter(Mandatory=$true)][string]$DotnetBundleOutput,
[Parameter(Mandatory=$true)][string]$WixRoot,
[Parameter(Mandatory=$true)][string]$ProductMoniker,
@ -78,7 +78,7 @@ function RunCandleForBundle
-ext WixBalExtension.dll `
-ext WixUtilExtension.dll `
-ext WixTagExtension.dll `
"$AuthWsxRoot\bundle.wxs"
"$AuthWsxRoot\bundle.wxs" "$WorkloadManifestWxsFile"
Write-Information "Candle output: $candleOutput"
@ -97,11 +97,14 @@ function RunLightForBundle
$result = $true
pushd "$WixRoot"
$WorkloadManifestWixobjFile = [System.IO.Path]::GetFileNameWithoutExtension($WorkloadManifestWxsFile) + ".wixobj"
Write-Information "Running light for bundle.."
$lightOutput = .\light.exe -nologo `
-cultures:en-us `
bundle.wixobj `
$WorkloadManifestWixobjFile `
$ASPNETRuntimeWixlibFile `
-ext WixBalExtension.dll `
-ext WixUtilExtension.dll `

View file

@ -1,153 +0,0 @@
# Copyright (c) .NET Foundation and contributors. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
param(
[Parameter(Mandatory=$true)][string]$inputDir,
[Parameter(Mandatory=$true)][string]$DotnetMSIOutput,
[Parameter(Mandatory=$true)][string]$WixRoot,
[Parameter(Mandatory=$true)][string]$ProductMoniker,
[Parameter(Mandatory=$true)][string]$DotnetMSIVersion,
[Parameter(Mandatory=$true)][string]$SDKBundleVersion,
[Parameter(Mandatory=$true)][string]$DotnetCLINugetVersion,
[Parameter(Mandatory=$true)][string]$UpgradeCode,
[Parameter(Mandatory=$true)][string]$DependencyKeyName,
[Parameter(Mandatory=$true)][string]$Architecture
)
$InstallFileswsx = ".\manifest-install-files.wxs"
$InstallFilesWixobj = "manifest-install-files.wixobj"
function RunHeat
{
$result = $true
pushd "$WixRoot"
Write-Information "Running heat.."
$heatOutput = .\heat.exe dir `"$inputDir`" -template fragment `
-sreg -ag `
-var var.DotnetSrc `
-cg InstallFiles `
-srd `
-dr DOTNETHOME `
-out manifest-install-files.wxs
Write-Information "Heat output: $heatOutput"
if($LastExitCode -ne 0)
{
$result = $false
Write-Information "Heat failed with exit code $LastExitCode."
}
popd
Write-Information "RunHeat result: $result"
return $result
}
function RunCandle
{
$result = $true
pushd "$WixRoot"
Write-Information "Running candle.."
$candleOutput = .\candle.exe -nologo `
-dDotnetSrc="$inputDir" `
-dMicrosoftEula="$PSScriptRoot\dummyeula.rtf" `
-dProductMoniker="$ProductMoniker" `
-dBuildVersion="$DotnetMSIVersion" `
-dSDKBundleVersion="$SDKBundleVersion" `
-dNugetVersion="$DotnetCLINugetVersion" `
-dUpgradeCode="$UpgradeCode" `
-dDependencyKeyName="$DependencyKeyName" `
-arch "$Architecture" `
-ext WixDependencyExtension.dll `
"$PSScriptRoot\manifests.wxs" `
"$PSScriptRoot\provider.wxs" `
"$PSScriptRoot\dotnethome_x64.wxs" `
$InstallFileswsx
Write-Information "Candle output: $candleOutput"
if($LastExitCode -ne 0)
{
$result = $false
Write-Information "Candle failed with exit code $LastExitCode."
}
popd
return $result
}
function RunLight
{
$result = $true
pushd "$WixRoot"
Write-Information "Running light.."
$CabCache = Join-Path $WixRoot "cabcache"
$lightOutput = .\light.exe -nologo -ext WixUIExtension -ext WixDependencyExtension -ext WixUtilExtension `
-cultures:en-us `
manifests.wixobj `
provider.wixobj `
dotnethome_x64.wixobj `
$InstallFilesWixobj `
-b "$inputDir" `
-b "$PSScriptRoot" `
-reusecab `
-cc "$CabCache" `
-out $DotnetMSIOutput
Write-Information "Light output: $lightOutput"
if($LastExitCode -ne 0)
{
$result = $false
Write-Information "Light failed with exit code $LastExitCode."
}
popd
return $result
}
if(!(Test-Path $inputDir))
{
throw "$inputDir not found"
}
Write-Information "Creating manifests MSI at $DotnetMSIOutput"
if([string]::IsNullOrEmpty($WixRoot))
{
Exit -1
}
if(-Not (RunHeat))
{
Write-Information "Heat failed"
Exit -1
}
if(-Not (RunCandle))
{
Write-Information "Candle failed"
Exit -1
}
if(-Not (RunLight))
{
Write-Information "Light failed"
Exit -1
}
if(!(Test-Path $DotnetMSIOutput))
{
throw "Unable to create the manifests MSI."
Exit -1
}
Write-Information "Successfully created manifests MSI - $DotnetMSIOutput"
exit $LastExitCode