Add Shared Host MSI Authoring
Ideally in the project.json for the shared host we would just list the actual package that holds the shared host, instead of all of NetStandard.Library, but doing some leads to compliation errors, since publish wants to include a compile step that has a generated AssemblyAttributes file which references types like System.String.
This commit is contained in:
parent
29bc612565
commit
04d21e6693
9 changed files with 299 additions and 3 deletions
109
packaging/host/windows/generatemsi.ps1
Normal file
109
packaging/host/windows/generatemsi.ps1
Normal file
|
@ -0,0 +1,109 @@
|
|||
# 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]$SharedHostPublishRoot,
|
||||
[Parameter(Mandatory=$true)][string]$DotnetHostMSIOutput,
|
||||
[Parameter(Mandatory=$true)][string]$WixRoot,
|
||||
[Parameter(Mandatory=$true)][string]$DotnetMSIVersion,
|
||||
[Parameter(Mandatory=$true)][string]$DotnetCLIVersion,
|
||||
[Parameter(Mandatory=$true)][string]$Architecture,
|
||||
[Parameter(Mandatory=$true)][string]$WixObjRoot
|
||||
)
|
||||
|
||||
. "$PSScriptRoot\..\..\..\scripts\common\_common.ps1"
|
||||
$RepoRoot = Convert-Path "$PSScriptRoot\..\..\.."
|
||||
|
||||
function RunCandle
|
||||
{
|
||||
$result = $true
|
||||
pushd "$WixRoot"
|
||||
|
||||
Write-Host Running candle..
|
||||
$AuthWsxRoot = Join-Path $RepoRoot "packaging\host\windows"
|
||||
|
||||
.\candle.exe -nologo `
|
||||
-out "$WixObjRoot\" `
|
||||
-ext WixDependencyExtension.dll `
|
||||
-dHostSrc="$SharedHostPublishRoot" `
|
||||
-dMicrosoftEula="$RepoRoot\packaging\osx\resources\en.lproj\eula.rtf" `
|
||||
-dBuildVersion="$DotnetMSIVersion" `
|
||||
-dDisplayVersion="$DotnetCLIVersion" `
|
||||
-arch $Architecture `
|
||||
"$AuthWsxRoot\host.wxs" `
|
||||
"$AuthWsxRoot\provider.wxs" `
|
||||
"$AuthWsxRoot\registrykeys.wxs" | 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\host.wixobj" `
|
||||
"$WixObjRoot\provider.wixobj" `
|
||||
"$WixObjRoot\registrykeys.wixobj" `
|
||||
-out $DotnetHostMSIOutput | Out-Host
|
||||
|
||||
if($LastExitCode -ne 0)
|
||||
{
|
||||
$result = $false
|
||||
Write-Host "Light failed with exit code $LastExitCode."
|
||||
}
|
||||
|
||||
popd
|
||||
return $result
|
||||
}
|
||||
|
||||
if(!(Test-Path $SharedHostPublishRoot))
|
||||
{
|
||||
throw "$SharedHostPublishRoot not found"
|
||||
}
|
||||
|
||||
if(!(Test-Path $WixObjRoot))
|
||||
{
|
||||
throw "$WixObjRoot not found"
|
||||
}
|
||||
|
||||
Write-Host "Creating shared host MSI at $DotnetHostMSIOutput"
|
||||
|
||||
if([string]::IsNullOrEmpty($WixRoot))
|
||||
{
|
||||
Exit -1
|
||||
}
|
||||
|
||||
if(-Not (RunCandle))
|
||||
{
|
||||
Exit -1
|
||||
}
|
||||
|
||||
if(-Not (RunLight))
|
||||
{
|
||||
Exit -1
|
||||
}
|
||||
|
||||
if(!(Test-Path $DotnetHostMSIOutput))
|
||||
{
|
||||
throw "Unable to create the shared host msi."
|
||||
Exit -1
|
||||
}
|
||||
|
||||
Write-Host -ForegroundColor Green "Successfully created shared host MSI - $DotnetHostMSIOutput"
|
||||
|
||||
exit $LastExitCode
|
44
packaging/host/windows/host.wxs
Normal file
44
packaging/host/windows/host.wxs
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?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" />
|
||||
<ComponentGroupRef Id="AuthoredRegistryKeys"/>
|
||||
</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="Dotnet_CLI_SharedHost_$(var.Dotnet_DisplayVersion)" />
|
||||
</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>
|
||||
<Fragment>
|
||||
<ComponentGroup Id="InstallFiles">
|
||||
<Component Id="cmpCoreHost" Directory="DOTNETHOME" Guid="{45399BBB-DDA5-4386-A2E9-618FB3C54A18}">
|
||||
<File Id="fileCoreHostExe" KeyPath="yes" Source="$(var.HostSrc)\dotnet.exe" />
|
||||
</Component>
|
||||
</ComponentGroup>
|
||||
</Fragment>
|
||||
</Wix>
|
9
packaging/host/windows/provider.wxs
Normal file
9
packaging/host/windows/provider.wxs
Normal file
|
@ -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="Dotnet_CLI_SharedHost_$(var.Dotnet_DisplayVersion)" Directory="TARGETDIR" Win64="no" Guid="82516259-FF21-446E-A432-1FFCA5A02296">
|
||||
<dep:Provides Key="Dotnet_CLI_SharedHost_$(var.Dotnet_DisplayVersion)" />
|
||||
</Component>
|
||||
</Fragment>
|
||||
</Wix>
|
28
packaging/host/windows/registrykeys.wxs
Normal file
28
packaging/host/windows/registrykeys.wxs
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0"?>
|
||||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
|
||||
<?include "Variables.wxi" ?>
|
||||
<Fragment>
|
||||
<ComponentGroup Id="AuthoredRegistryKeys">
|
||||
<?if $(var.Platform) = x64?>
|
||||
<Component Id="SetupRegistry_x64" Directory="TARGETDIR" Win64="yes">
|
||||
<RegistryKey Root="HKLM" Key="SOFTWARE\dotnet\sharedhost\Setup">
|
||||
<RegistryValue Action="write" Name="Install" Type="integer" Value="1" KeyPath="yes"/>
|
||||
<RegistryValue Action="write" Name="InstallDir" Type="string" Value="[DOTNETHOME]" />
|
||||
<RegistryValue Action="write" Name="Version" Type="string" Value="$(var.Dotnet_ProductVersion)" />
|
||||
</RegistryKey>
|
||||
</Component>
|
||||
<?endif?>
|
||||
|
||||
<?if $(var.Platform) = x64?>
|
||||
<Component Id="SetupRegistry_x86" Directory="TARGETDIR" Win64="no">
|
||||
<RegistryKey Root="HKLM" Key="SOFTWARE\dotnet\sharedhost\Setup">
|
||||
<RegistryValue Action="write" Name="Install" Type="integer" Value="1" KeyPath="yes"/>
|
||||
<RegistryValue Action="write" Name="InstallDir" Type="string" Value="[DOTNETHOME]" />
|
||||
<RegistryValue Action="write" Name="Version" Type="string" Value="$(var.Dotnet_ProductVersion)" />
|
||||
</RegistryKey>
|
||||
</Component>
|
||||
<?endif?>
|
||||
|
||||
</ComponentGroup>
|
||||
</Fragment>
|
||||
</Wix>
|
29
packaging/host/windows/variables.wxi
Normal file
29
packaging/host/windows/variables.wxi
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0"?>
|
||||
<Include xmlns="http://schemas.microsoft.com/wix/2006/wi">
|
||||
|
||||
<?define Servicing_Key_SP = "0" ?>
|
||||
<?define Servicing_Key_SPIndex = "0" ?>
|
||||
<?define Servicing_Key_SPName = "Beta" ?>
|
||||
<?define Dotnet_ProductVersion = "$(var.BuildVersion)" ?>
|
||||
<?define Dotnet_DisplayVersion = "$(var.DisplayVersion)" ?>
|
||||
<?define Dotnet_BuildVersion = "$(var.BuildVersion)" ?>
|
||||
<?define Manufacturer = "Microsoft Corporation" ?>
|
||||
<?define ProductName = "Microsoft .NET Core Host for Windows ($(var.DisplayVersion))" ?>
|
||||
<?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?>
|
||||
<?define UpgradeCode="66EBF603-F032-4595-B914-10CC99BBED86"?>
|
||||
<?elseif $(var.Platform)=x64?>
|
||||
<?define Program_Files="ProgramFiles64Folder"?>
|
||||
<?define Win64AttributeValue=yes?>
|
||||
<?define UpgradeCode="4553594B-D821-40E0-9A54-9697B13E344C"?>
|
||||
<?else?>
|
||||
<?error Invalid Platform ($(var.Platform))?>
|
||||
<?endif?>
|
||||
</Include>
|
|
@ -26,6 +26,8 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
|
||||
private static string SdkBundle { get; set; }
|
||||
|
||||
private static string SharedHostMsi { get; set; }
|
||||
|
||||
private static string Engine { get; set; }
|
||||
|
||||
private static string MsiVersion { get; set; }
|
||||
|
@ -64,6 +66,8 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
SdkMsi = Path.ChangeExtension(SdkBundle, "msi");
|
||||
Engine = Path.Combine(Path.GetDirectoryName(SdkBundle), ENGINE);
|
||||
|
||||
SharedHostMsi = Path.ChangeExtension(c.BuildContext.Get<string>("SharedHostInstallerFile"), "msi");
|
||||
|
||||
var buildVersion = c.BuildContext.Get<BuildVersion>("BuildVersion");
|
||||
MsiVersion = buildVersion.GenerateMsiVersion();
|
||||
CliVersion = buildVersion.SimpleVersion;
|
||||
|
@ -74,7 +78,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
}
|
||||
|
||||
[Target(nameof(MsiTargets.InitMsi),
|
||||
nameof(GenerateDotnetMuxerMsi),
|
||||
nameof(GenerateDotnetSharedHostMsi),
|
||||
nameof(GenerateDotnetSharedFxMsi),
|
||||
nameof(GenerateCliSdkMsi))]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
|
@ -95,10 +99,25 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
return c.Success();
|
||||
}
|
||||
|
||||
[Target]
|
||||
[Target(nameof(SharedFrameworkTargets.PublishSharedHost))]
|
||||
[BuildPlatforms(BuildPlatform.Windows)]
|
||||
public static BuildTargetResult GenerateDotnetMuxerMsi(BuildTargetContext c)
|
||||
public static BuildTargetResult GenerateDotnetSharedHostMsi(BuildTargetContext c)
|
||||
{
|
||||
var inputDir = c.BuildContext.Get<string>("SharedHostPublishRoot");
|
||||
var wixObjRoot = Path.Combine(Dirs.Output, "obj", "wix", "sharedhost");
|
||||
|
||||
if (Directory.Exists(wixObjRoot))
|
||||
{
|
||||
Directory.Delete(wixObjRoot, true);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(wixObjRoot);
|
||||
|
||||
Cmd("powershell", "-NoProfile", "-NoLogo",
|
||||
Path.Combine(Dirs.RepoRoot, "packaging", "host", "windows", "generatemsi.ps1"),
|
||||
inputDir, SharedHostMsi, WixRoot, MsiVersion, CliVersion, Arch, wixObjRoot)
|
||||
.Execute()
|
||||
.EnsureSuccessful();
|
||||
return c.Success();
|
||||
}
|
||||
|
||||
|
|
|
@ -113,6 +113,7 @@ namespace Microsoft.DotNet.Cli.Build
|
|||
c.BuildContext["VersionBadge"] = Path.Combine(Dirs.Output, versionBadgeName);
|
||||
|
||||
AddInstallerArtifactToContext(c, "dotnet", "Sdk");
|
||||
AddInstallerArtifactToContext(c, "dotnet-host", "SharedHost");
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
|
|
46
scripts/dotnet-cli-build/SharedFrameworkTargets.cs
Normal file
46
scripts/dotnet-cli-build/SharedFrameworkTargets.cs
Normal file
|
@ -0,0 +1,46 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class SharedFrameworkTargets
|
||||
{
|
||||
private const string CoreHostBaseName = "corehost";
|
||||
|
||||
[Target]
|
||||
public static BuildTargetResult PublishSharedHost(BuildTargetContext c)
|
||||
{
|
||||
string SharedHostPublishRoot = Path.Combine(Dirs.Output, "obj", "sharedhost");
|
||||
|
||||
if (Directory.Exists(SharedHostPublishRoot))
|
||||
{
|
||||
Directory.Delete(SharedHostPublishRoot, true);
|
||||
}
|
||||
|
||||
DotNetCli.Stage0.Publish("--output", SharedHostPublishRoot, Path.Combine(Dirs.RepoRoot, "src", "sharedframework", "host")).Execute().EnsureSuccessful();
|
||||
|
||||
// For the shared host, we only want corerun and not any of the other artifacts in the package (like the hostpolicy)
|
||||
foreach (var filePath in Directory.GetFiles(SharedHostPublishRoot))
|
||||
{
|
||||
if (Path.GetFileName(filePath) != $"{CoreHostBaseName}{Constants.ExeSuffix}")
|
||||
{
|
||||
File.Delete(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
// corehost will be renamed to dotnet at some point and then this can be removed.
|
||||
File.Move(Path.Combine(SharedHostPublishRoot, $"{CoreHostBaseName}{Constants.ExeSuffix}"), Path.Combine(SharedHostPublishRoot, $"dotnet{Constants.ExeSuffix}"));
|
||||
|
||||
c.BuildContext["SharedHostPublishRoot"] = SharedHostPublishRoot;
|
||||
|
||||
return c.Success();
|
||||
}
|
||||
}
|
||||
}
|
11
src/sharedframework/host/project.json
Normal file
11
src/sharedframework/host/project.json
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.0.0-rc2-23811"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"dnxcore50": { }
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue