Create targeting pack MSI installers (#5114)

* Create targeting pack MSI

This change has the targeting pack pkgproj create an install layout based on the nupkg's data/ dir. That's picked up by the targeting pack installer project the same way it is for hostfxr and shared framework. In general, the targeting pack installer project is a copy of existing installers with very little changed.

In official builds, build the full platform manifest on win-x86, not just win-x64. Both platforms' installers need the full manifest.

* Change install dir "ref" => "packs"

* "Microsoft .NET Core Targeting Pack" branding

* Remove "netcoreapp" from MSI filename

The name "dotnet-targeting-pack" brings it in line with installer names like "dotnet-runtime" and "dotnet-host".

* Fix targeting pack powershell script: PR comments

I plan to remove this script entirely, but it might as well be a little cleaner while development is ongoing.

* Fix DependencyKey: Dotnet_CLI => Dotnet_Core

* Fix typo: GeneratedGui => GeneratedGuid
This commit is contained in:
Davis Goodin 2019-02-13 18:35:25 -06:00 коммит произвёл GitHub
Родитель 52765f25ad
Коммит 0f10c29471
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
10 изменённых файлов: 294 добавлений и 6 удалений

Просмотреть файл

@ -179,6 +179,7 @@ jobs:
# Windows x86
- template: /eng/jobs/windows-build.yml
parameters:
buildFullPlatformManifest: true
displayName: Build_Windows_x86
targetArchitecture: x86

Просмотреть файл

@ -286,11 +286,14 @@
<DotnetHostString>dotnet-host-</DotnetHostString>
<DotnetHostFxrString>dotnet-hostfxr-</DotnetHostFxrString>
<DotnetRuntimeString>dotnet-runtime-</DotnetRuntimeString>
<DotnetTargetingPackString>dotnet-targeting-pack-</DotnetTargetingPackString>
<DotnetRuntimeDependenciesPackageString>dotnet-runtime-deps-</DotnetRuntimeDependenciesPackageString>
<CombinedInstallerStart>$(AssetOutputPath)$(DotnetRuntimeString)</CombinedInstallerStart>
<SharedHostInstallerStart>$(AssetOutputPath)$(DotnetHostString)</SharedHostInstallerStart>
<HostFxrInstallerStart>$(AssetOutputPath)$(DotnetHostFxrString)</HostFxrInstallerStart>
<SharedFrameworkInstallerStart>$(AssetOutputPath)$(DotnetRuntimeString)</SharedFrameworkInstallerStart>
<TargetingPackInstallerStart>$(AssetOutputPath)$(DotnetTargetingPackString)</TargetingPackInstallerStart>
<DotnetRuntimeDependenciesPackageInstallerStart>$(AssetOutputPath)$(DotnetRuntimeDependenciesPackageString)</DotnetRuntimeDependenciesPackageInstallerStart>
<!-- OSX specific intermediate package suffix . OSX specific intermediate packages are suffixed with -internal to avoid name collision for bundle package (dotnet-runtime-*)
@ -299,6 +302,7 @@
<SharedHostInstallerStart Condition="'$(OSGroup)' == 'OSX'">$(SharedHostInstallerStart)$(InstallerStartSuffix)-</SharedHostInstallerStart>
<HostFxrInstallerStart Condition="'$(OSGroup)' == 'OSX'">$(HostFxrInstallerStart)$(InstallerStartSuffix)-</HostFxrInstallerStart>
<SharedFrameworkInstallerStart Condition="'$(OSGroup)' == 'OSX'">$(SharedFrameworkInstallerStart)$(InstallerStartSuffix)-</SharedFrameworkInstallerStart>
<TargetingPackInstallerStart Condition="'$(OSGroup)' == 'OSX'">$(TargetingPackInstallerStart)$(InstallerStartSuffix)-</TargetingPackInstallerStart>
</PropertyGroup>
@ -429,9 +433,12 @@
<PropertyGroup>
<CombinedInstallerFile>$(CombinedInstallerStart)$(ProductMoniker)$(CombinedInstallerExtension)</CombinedInstallerFile>
<CombinedInstallerEngine>$(CombinedInstallerStart)$(ProductMoniker)-engine.exe</CombinedInstallerEngine>
<SharedHostInstallerFile>$(SharedHostInstallerStart)$(ProductMoniker)$(InstallerExtension)</SharedHostInstallerFile>
<HostFxrInstallerFile>$(HostFxrInstallerStart)$(HostResolverVersionMoniker)$(InstallerExtension)</HostFxrInstallerFile>
<SharedFrameworkInstallerFile>$(SharedFrameworkInstallerStart)$(ProductMoniker)$(InstallerExtension)</SharedFrameworkInstallerFile>
<TargetingPackInstallerFile>$(TargetingPackInstallerStart)$(ProductMoniker)$(InstallerExtension)</TargetingPackInstallerFile>
<!-- Runtime Deb and Rpm packages are distro version agnostic -->
<SharedHostInstallerFile Condition="'$(InstallerExtension)' == '.deb' or '$(InstallerExtension)' == '.rpm' ">$(SharedHostInstallerStart)$(SharedFrameworkNugetVersion)-$(TargetArchitecture)$(InstallerExtension)</SharedHostInstallerFile>
<HostFxrInstallerFile Condition="'$(InstallerExtension)' == '.deb' or '$(InstallerExtension)' == '.rpm'">$(HostFxrInstallerStart)$(HostResolverVersion)-$(TargetArchitecture)$(InstallerExtension)</HostFxrInstallerFile>

Просмотреть файл

@ -8,10 +8,12 @@
<!-- Package prebuilt binaries -->
<UsePrebuiltPortableBinariesForInstallers>false</UsePrebuiltPortableBinariesForInstallers>
<!-- Use trailing '/'. Heat.exe doesn't accept a trailing '\'.-->
<PackagesIntermediateDir>$(IntermediateOutputRootPath)packages/</PackagesIntermediateDir>
<SharedHostPublishRoot>$(IntermediateOutputRootPath)sharedHost/</SharedHostPublishRoot>
<HostFxrPublishRoot>$(IntermediateOutputRootPath)hostFxr/</HostFxrPublishRoot>
<SharedFrameworkPublishRoot>$(IntermediateOutputRootPath)sharedFx/</SharedFrameworkPublishRoot>
<TargetingPackPublishRoot>$(IntermediateOutputRootPath)Microsoft.NETCore.App.Ref/layout/</TargetingPackPublishRoot>
<CombinedPublishRoot>$(IntermediateOutputRootPath)combined-framework-host/</CombinedPublishRoot>
</PropertyGroup>
@ -28,6 +30,7 @@
<ProductBrandSuffix Condition="'$(ReleaseBrandSuffix)'!=''">$(ProductionVersion) $(ReleaseBrandSuffix)</ProductBrandSuffix>
<SharedHostBrandName>$(ProductBrandPrefix) Host - $(ProductBrandSuffix)</SharedHostBrandName>
<HostFxrBrandName>$(ProductBrandPrefix) Host FX Resolver - $(ProductBrandSuffix)</HostFxrBrandName>
<TargetingPackBrandName>$(ProductBrandPrefix) Targeting Pack - $(ProductBrandSuffix)</TargetingPackBrandName>
<SharedFrameworkBrandName>$(ProductBrandPrefix) Runtime - $(ProductBrandSuffix)</SharedFrameworkBrandName>
</PropertyGroup>
</Project>

Просмотреть файл

@ -40,11 +40,15 @@
OverwriteDestination="false" />
<GenerateGuidFromName Name="$(SharedHostInstallerFile)">
<Output TaskParameter="GeneratedGui" PropertyName="SharedHostUpgradeCode" />
<Output TaskParameter="GeneratedGuid" PropertyName="SharedHostUpgradeCode" />
</GenerateGuidFromName>
<GenerateGuidFromName Name="$(HostFxrInstallerFile)">
<Output TaskParameter="GeneratedGui" PropertyName="HostFxrUpgradeCode" />
<Output TaskParameter="GeneratedGuid" PropertyName="HostFxrUpgradeCode" />
</GenerateGuidFromName>
<GenerateGuidFromName Name="$(TargetingPackInstallerFile)">
<Output TaskParameter="GeneratedGuid" PropertyName="TargetingPackUpgradeCode" />
</GenerateGuidFromName>
<ItemGroup>
@ -60,6 +64,12 @@
<InstallerName>$(HostFxrInstallerFile)</InstallerName>
<UpgradeCode>$(HostFxrUpgradeCode)</UpgradeCode>
</WixOutputs>
<WixOutputs Include="$(WixObjRoot)targetingpack">
<InputDir>$(TargetingPackPublishRoot)</InputDir>
<BrandName>$(TargetingPackBrandName)</BrandName>
<InstallerName>$(TargetingPackInstallerFile)</InstallerName>
<UpgradeCode>$(TargetingPackUpgradeCode)</UpgradeCode>
</WixOutputs>
<!-- shared framework has extra arguments so it needs to be in a separate group -->
<WixOutputs2 Include="$(WixObjRoot)sharedframework">
<InputDir>$(SharedFrameworkPublishRoot)</InputDir>
@ -72,7 +82,7 @@
<MakeDir Directories="$(WixObjRoot);@(WixOutputs);@(WixOutputs2)" />
<GenerateGuidFromName Name="$(SharedFrameworkInstallerFile)">
<Output TaskParameter="GeneratedGui" PropertyName="SharedFxUpgradeCode" />
<Output TaskParameter="GeneratedGuid" PropertyName="SharedFxUpgradeCode" />
</GenerateGuidFromName>
<PropertyGroup>
@ -100,7 +110,7 @@
</PropertyGroup>
<GenerateGuidFromName Name="$(SharedBundle)">
<Output TaskParameter="GeneratedGui" PropertyName="SharedBundleCode" />
<Output TaskParameter="GeneratedGuid" PropertyName="SharedBundleCode" />
</GenerateGuidFromName>
<PropertyGroup>

Просмотреть файл

@ -0,0 +1,161 @@
# 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]$TargetingPackPublishRoot,
[Parameter(Mandatory=$true)][string]$TargetingPackMSIOutput,
[Parameter(Mandatory=$true)][string]$WixRoot,
[Parameter(Mandatory=$true)][string]$ProductMoniker,
[Parameter(Mandatory=$true)][string]$TargetingPackMSIVersion,
[Parameter(Mandatory=$true)][string]$TargetingPackNugetVersion,
[Parameter(Mandatory=$true)][string]$Architecture,
[Parameter(Mandatory=$true)][string]$TargetArchitecture,
[Parameter(Mandatory=$true)][string]$WixObjRoot,
[Parameter(Mandatory=$true)][string]$TargetingPackUpgradeCode
)
$RepoRoot = Convert-Path "$PSScriptRoot\..\..\..\..\.."
$CommonScript = "$RepoRoot\tools-local\scripts\common\_common.ps1"
if(-Not (Test-Path "$CommonScript"))
{
Exit -1
}
. "$CommonScript"
$PackagingRoot = Join-Path $RepoRoot "src\pkg\packaging"
$InstallFileswsx = "$WixObjRoot\install-files.wxs"
$InstallFilesWixobj = "$WixObjRoot\install-files.wixobj"
function RunHeat
{
$Result = $true
pushd "$WixRoot"
Write-Host Running heat.. to $InstallFileswsx
Write-Host "Root $TargetingPackPublishRoot"
.\heat.exe dir `"$TargetingPackPublishRoot`" `
-nologo `
-template fragment `
-sreg -gg `
-var var.TargetingPackSrc `
-cg InstallFiles `
-srd `
-dr DOTNETHOME `
-out $InstallFileswsx | Out-Host
if($LastExitCode -ne 0)
{
$Result = $false
Write-Host "Heat failed with exit code $LastExitCode."
}
popd
return $Result
}
function RunCandle
{
$Result = $true
pushd "$WixRoot"
Write-Host Running candle..
$AuthWsxRoot = Join-Path $PackagingRoot "windows\targetingpack"
$ComponentVersion = $TargetingPackNugetVersion.Replace('-', '_');
.\candle.exe -nologo `
-out "$WixObjRoot\" `
-dTargetingPackSrc="$TargetingPackPublishRoot" `
-dMicrosoftEula="$PackagingRoot\windows\eula.rtf" `
-dProductMoniker="$ProductMoniker" `
-dBuildVersion="$TargetingPackMSIVersion" `
-dNugetVersion="$TargetingPackNugetVersion" `
-dComponentVersion="$ComponentVersion" `
-dTargetArchitecture="$TargetArchitecture" `
-dUpgradeCode="$TargetingPackUpgradeCode" `
-arch $Architecture `
-ext WixDependencyExtension.dll `
"$AuthWsxRoot\targetingpack.wxs" `
"$AuthWsxRoot\provider.wxs" `
$InstallFileswsx | Out-Host
if($LastExitCode -ne 0)
{
$Result = $false
Write-Host "Candle failed with exit code $LastExitCode."
}
popd
return $Result
}
function RunLight
{
$Result = $true
pushd "$WixRoot"
Write-Host Running light..
.\light.exe -nologo `
-ext WixUIExtension.dll `
-ext WixDependencyExtension.dll `
-ext WixUtilExtension.dll `
-cultures:en-us `
"$WixObjRoot\targetingpack.wixobj" `
"$WixObjRoot\provider.wixobj" `
"$InstallFilesWixobj" `
-out $TargetingPackMSIOutput | Out-Host
if($LastExitCode -ne 0)
{
$Result = $false
Write-Host "Light failed with exit code $LastExitCode."
}
popd
return $Result
}
if(!(Test-Path $TargetingPackPublishRoot))
{
throw "$TargetingPackPublishRoot not found"
}
if(!(Test-Path $WixObjRoot))
{
throw "$WixObjRoot not found"
}
Write-Host "Creating Targeting Pack MSI at $TargetingPackMSIOutput"
if([string]::IsNullOrEmpty($WixRoot))
{
Exit -1
}
if(-Not (RunHeat))
{
Exit -1
}
if(-Not (RunCandle))
{
Exit -1
}
if(-Not (RunLight))
{
Exit -1
}
if(!(Test-Path $TargetingPackMSIOutput))
{
throw "Unable to create the Targeting Pack MSI."
}
Write-Host -ForegroundColor Green "Successfully created Targeting Pack MSI - $TargetingPackMSIOutput"
exit $LastExitCode

Просмотреть файл

@ -0,0 +1,9 @@
<?xml version="1.0"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:dep="http://schemas.microsoft.com/wix/DependencyExtension">
<?include "Variables.wxi" ?>
<Fragment>
<Component Id="$(var.DependencyKeyId)" Directory="TARGETDIR" Win64="no" Guid="117B1755-5027-4257-A1A9-7C37D81C3D5F">
<dep:Provides Key="$(var.DependencyKey)" />
</Component>
</Fragment>
</Wix>

Просмотреть файл

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?include "Variables.wxi" ?>
<Product Id="*" Name="$(var.ProductName)" Language="$(var.ProductLanguage)" Version="$(var.ProductVersion)" Manufacturer="$(var.Manufacturer)" UpgradeCode="$(var.UpgradeCode)">
<Package Compressed="yes" InstallScope="perMachine" InstallerVersion="200" />
<MajorUpgrade DowngradeErrorMessage="$(var.DowngradeErrorMessage)" Schedule="afterInstallInitialize"/>
<MediaTemplate CompressionLevel="high" EmbedCab="yes" />
<Feature Id="MainFeature" Title="Main Feature" Level="1">
<ComponentGroupRef Id="InstallFiles" />
</Feature>
<Feature Id="Provider" Absent="disallow" AllowAdvertise="no" Description="Used for Ref Counting" Display="hidden" Level="1" InstallDefault="local" Title="RefCounting" TypicalDefault="install">
<ComponentRef Id="$(var.DependencyKeyId)" />
</Feature>
<Property Id="ProductCPU" Value="$(var.Platform)" />
<Property Id="RTM_ProductVersion" Value="$(var.Dotnet_ProductVersion)" />
<Property Id="MSIFASTINSTALL" Value="7" />
<WixVariable Id="WixUILicenseRtf" Value="$(var.MicrosoftEula)" />
<Property Id="WIXUI_INSTALLDIR" Value="DOTNETHOME"/>
<UIRef Id="WixUI_InstallDir" />
<CustomActionRef Id="WixBroadcastEnvironmentChange" />
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="$(var.Program_Files)">
<Directory Id="DOTNETHOME" Name="dotnet"/>
</Directory>
</Directory>
</Fragment>
</Wix>

Просмотреть файл

@ -0,0 +1,26 @@
<?xml version="1.0"?>
<Include xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?define Dotnet_ProductVersion = "$(var.BuildVersion)" ?>
<?define Dotnet_BuildVersion = "$(var.BuildVersion)" ?>
<?define Manufacturer = "Microsoft Corporation" ?>
<?define ProductName = "$(var.ProductMoniker) ($(var.TargetArchitecture))" ?>
<?define ProductLanguage = "1033" ?>
<?define ProductVersion = "$(var.Dotnet_ProductVersion)" ?>
<?define LCID = "$(var.ProductLanguage)"?>
<?define DowngradeErrorMessage = "A newer version is already installed; please uninstall it and re-run setup."?>
<?define Platform = "$(sys.BUILDARCH)" ?>
<?if $(var.Platform)=x86?>
<?define Program_Files="ProgramFilesFolder"?>
<?define Win64AttributeValue=no?>
<?elseif $(var.Platform)=x64?>
<?define Program_Files="ProgramFiles64Folder"?>
<?define Win64AttributeValue=yes?>
<?else?>
<?error Invalid Platform ($(var.Platform))?>
<?endif?>
<?define DependencyKey = "Dotnet_Core_TargetingPack_$(var.BuildVersion)_$(var.Platform)"?>
<?define DependencyKeyId = "$(var.DependencyKey)" ?>
</Include>

Просмотреть файл

@ -18,6 +18,9 @@
<!-- Remove package dependencies. -->
<ExcludeLineupReference>true</ExcludeLineupReference>
<PackProjectDependencies>false</PackProjectDependencies>
<!-- Location to lay out data/ dir. Used later to create installers. -->
<DataLayoutDir>$(IntermediateOutputPath)layout/</DataLayoutDir>
</PropertyGroup>
<!-- Redistribute package content from other nuget packages. -->
@ -39,4 +42,35 @@
</ItemGroup>
</Target>
<!--
Copy the files in the package's data/ dir to a layout directory. This is what the targeting pack
installer will place in the dotnet install dir.
This extracts from the nupkg (zip) directly. An alternative would be using the PackageFile
items, but there's some risk of handling TargetPath metadata differently than NuGet does. Using
the nupkg directly ensures results are identical.
-->
<Target Name="CreateTargetingPackLayout"
AfterTargets="CreatePackage">
<PropertyGroup>
<TargetingPackNupkgFile>$(PackageOutputPath)$(Id).$(PackageVersion).nupkg</TargetingPackNupkgFile>
</PropertyGroup>
<ZipFileGetEntries TargetArchive="$(TargetingPackNupkgFile)">
<Output TaskParameter="Entries" ItemName="TargetingPackNupkgEntries" />
</ZipFileGetEntries>
<ItemGroup>
<TargetingPackDataEntries
Include="@(TargetingPackNupkgEntries)"
Condition="$([System.String]::new('%(TargetingPackNupkgEntries.Identity)').StartsWith('data/'))" />
</ItemGroup>
<ZipFileExtractToDirectory
SourceArchive="$(TargetingPackNupkgFile)"
DestinationDirectory="$(DataLayoutDir)packs/$(Id)/$(Version)/"
OverwriteDestination="true"
Include="@(TargetingPackDataEntries)" />
</Target>
</Project>

Просмотреть файл

@ -12,8 +12,9 @@ namespace Microsoft.DotNet.Build.Tasks
{
[Required]
public string Name { get; set; }
[Output]
public string GeneratedGui { get; set; }
public string GeneratedGuid { get; set; }
// Generate a Version 5 (SHA1 Name Based) Guid from a name.
public override bool Execute()
@ -44,7 +45,7 @@ namespace Microsoft.DotNet.Build.Tasks
SwapGuidByteOrder(res);
GeneratedGui = (new Guid(res)).ToString();
GeneratedGuid = (new Guid(res)).ToString();
}
return true;