Merge pull request #211 from Sridhar-MS/msi-packaging

First pass at building Windows MSI for the dotnet CLI repo.
This commit is contained in:
Piotr Puszkiewicz 2015-11-18 01:27:10 -08:00
commit 080a127c38
10 changed files with 311 additions and 4 deletions

View file

@ -0,0 +1,14 @@
// 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.
namespace WiX.Toolset.2015
{
public class Program
{
public static int Main(string[] args)
{
// Temporary and bogus. Just needed so we can publish this
return 1;
}
}
}

View file

@ -0,0 +1,3 @@
# WiX.Toolset.2015
This is a utility project that brings the Wix Tools down and lets us publish it as though it were an app. Do NOT add any C# code to it! It is not designed to actually be compiled as an assembly, it's just used for its dependencies.

View file

@ -0,0 +1,13 @@
{
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"WiX": "3.10.0.2103-pre1"
},
"frameworks": {
"dnxcore50": { }
}
}

View file

@ -0,0 +1,43 @@
<?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" InstallerVersion="200" />
<Upgrade Id="$(var.UpgradeCode)">
<UpgradeVersion Minimum="$(var.ProductVersion)" IncludeMinimum="no" OnlyDetect="yes" Property="NEWERVERSIONDETECTED" Language="$(var.LCID)" />
<UpgradeVersion Minimum="0.0.0.0" Maximum="$(var.ProductVersion)" IncludeMinimum="no" IncludeMaximum="no" Property="WIX_DOWNGRADE_DETECTED" Language="$(var.LCID)" />
</Upgrade>
<InstallExecuteSequence>
<RemoveExistingProducts Before="InstallInitialize" />
</InstallExecuteSequence>
<MediaTemplate CompressionLevel="mszip" EmbedCab="yes"/>
<Feature Id="MainFeature" Title="Main Feature" Level="1">
<ComponentGroupRef Id="InstallFiles" />
<ComponentRef Id="SetEnvVars" />
<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_$(var.Dotnet_DisplayVersion)" />
</Feature>
<Property Id="ProductFamily" Value="$(var.ProductFamily)" />
<Property Id="ProductEdition" Value="$(var.ProductEdition)" />
<Property Id="ProductCPU" Value="$(var.Platform)" />
<Property Id="RTM_ProductVersion" Value="$(var.Dotnet_ProductVersion)" />
<!--Property Id="ARPNOMODIFY" Value="1" /-->
<WixVariable Id="WixUILicenseRtf" Value="$(var.MicrosoftEula)" />
<Property Id="WIXUI_INSTALLDIR" Value="DOTNETHOME"/>
<UIRef Id="WixUI_InstallDir" />
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="$(var.Program_Files)" Name="$(var.Program_Files)">
<Directory Id="ProgramFilesFolder.Microsoft" Name="Microsoft">
<Directory Id="DOTNETHOME" Name="dotnet"/>
</Directory>
</Directory>
</Directory>
</Fragment>
</Wix>

View file

@ -0,0 +1,13 @@
<?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>
<DirectoryRef Id="TARGETDIR">
<Component Id="SetEnvVars" Guid="{E503A496-DE1B-4646-81D4-47213B4CCFAF}">
<Environment Id="E_PATH" Name="PATH" Value="[DOTNETHOME]bin" Permanent="no" Part="last" Action="set" System="yes" />
<Environment Id="E_DOTNET_HOME" Name="DOTNET_HOME" Value="[DOTNETHOME]" Permanent="no" Part="all" Action="set" System="yes" />
</Component>
</DirectoryRef>
<CustomActionRef Id="WixBroadcastEnvironmentChange" />
</Fragment>
</Wix>

View file

@ -0,0 +1,158 @@
# 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(
[string]$inputDir = $(throw "Specify the full path to the directory which needs to be harvested")
)
. "$PSScriptRoot\..\..\scripts\_common.ps1"
$DotnetMSIOutput = ""
$WixRoot = ""
$InstallFileswsx = "install-files.wxs"
$InstallFilesWixobj = "install-files.wixobj"
function AcquireWixTools
{
pushd "$Stage2Dir\bin"
Write-Host Restoring Wixtools..
$result = $env:TEMP
.\dotnet restore $RepoRoot\packaging\windows\WiXTools --packages $result | Out-Null
if($LastExitCode -ne 0)
{
$result = ""
Write-Host "dotnet restore failed with exit code $LastExitCode."
}
else
{
$result = Join-Path $result WiX\3.10.0.2103-pre1\tools
}
popd
return $result
}
function RunHeat
{
$result = $true
pushd "$WixRoot"
Write-Host Running heat..
.\heat.exe dir `"$inputDir`" -template fragment -sreg -gg -var var.DotnetSrc -cg InstallFiles -srd -dr DOTNETHOME -out $InstallFileswsx | Out-Null
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 $RepoRoot "packaging\windows"
.\candle.exe -dDotnetSrc="$inputDir" -dMicrosoftEula="$RepoRoot\packaging\osx\resources\en.lproj\eula.rtf" -dBuildVersion="$env:DOTNET_BUILD_VERSION" -arch x64 `
-ext WixDependencyExtension.dll `
"$AuthWsxRoot\dotnet.wxs" `
"$AuthWsxRoot\envvars.wxs" `
"$AuthWsxRoot\provider.wxs" `
"$AuthWsxRoot\registrykeys.wxs" `
$InstallFileswsx | Out-Null
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 -ext WixUIExtension -ext WixDependencyExtension -ext WixUtilExtension `
-cultures:en-us `
dotnet.wixobj `
envvars.wixobj `
provider.wixobj `
registrykeys.wixobj `
$InstallFilesWixobj `
-out $DotnetMSIOutput | Out-Null
if($LastExitCode -ne 0)
{
$result = $false
Write-Host "Light failed with exit code $LastExitCode."
}
popd
return $result
}
if(!(Test-Path $inputDir))
{
throw "$inputDir not found"
}
if(!(Test-Path $PackageDir))
{
mkdir $PackageDir | Out-Null
}
$DotnetMSIOutput = Join-Path $PackageDir "dotnet-win-x64.$env:DOTNET_BUILD_VERSION.msi"
Write-Host "Creating dotnet MSI at $DotnetMSIOutput"
$WixRoot = AcquireWixTools
if([string]::IsNullOrEmpty($WixRoot))
{
return -1
}
if(-Not (RunHeat))
{
return -1
}
if(-Not (RunCandle))
{
return -1
}
if(-Not (RunLight))
{
return -1
}
if(!(Test-Path $DotnetMSIOutput))
{
throw "Unable to create the dotnet msi."
return -1
}
Write-Host -ForegroundColor Green "Successfully create dotnet MSI - $DotnetMSIOutput"
$PublishScript = Join-Path $PSScriptRoot "..\..\scripts\publish\publish.ps1"
& $PublishScript -file $DotnetMSIOutput
exit $LastExitCode

View file

@ -0,0 +1,11 @@
<?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>
<DirectoryRef Id="TARGETDIR">
<Component Id="Dotnet_CLI_$(var.Dotnet_DisplayVersion)" DiskId="1" Win64="no" Guid="3B7DF8C8-9BB9-3F4C-8CBF-E393E4D7FF43">
<dep:Provides Key="Dotnet.CLI_$(var.Dotnet_DisplayVersion)" />
</Component>
</DirectoryRef>
</Fragment>
</Wix>

View file

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?include "Variables.wxi" ?>
<Fragment>
<ComponentGroup Id="AuthoredRegistryKeys">
<Component Directory="TARGETDIR" Guid="*" Win64="$(var.Win64AttributeValue)">
<RegistryKey Root="HKLM" Key="SOFTWARE\Microsoft\Dotnet CLI\Setup">
<RegistryValue Action="write" Name="Install" Type="integer" Value="1" />
<RegistryValue Action="write" Name="InstallDir" Type="string" Value="[DOTNETHOME]" />
<RegistryValue Action="write" Name="Version" Type="string" Value="$(var.Dotnet_ProductVersion)" />
</RegistryKey>
</Component>
</ComponentGroup>
</Fragment>
</Wix>

View 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 = "1.0" ?>
<?define Dotnet_BuildVersion = "$(var.BuildVersion)" ?>
<?define Manufacturer = "Microsoft Corporation" ?>
<?define ProductName = "Microsoft Dotnet CLI for Windows" ?>
<?define ProductLanguage = "1033" ?>
<?define ProductVersion = "$(var.Dotnet_ProductVersion)" ?>
<?define ProductFamily = "dotnet" ?>
<?define ProductEdition = "001dotnet" ?>
<?define LCID = "$(var.ProductLanguage)"?>
<?define Platform = "$(sys.BUILDARCH)" ?>
<?if $(var.Platform)=x86?>
<?define Program_Files="ProgramFilesFolder"?>
<?define Win64AttributeValue=no?>
<?define UpgradeCode="70A1576F-63B6-4659-9E39-25C7B769DDE5"?>
<?elseif $(var.Platform)=x64?>
<?define Program_Files="ProgramFiles64Folder"?>
<?define Win64AttributeValue=yes?>
<?define UpgradeCode="7D73E4F7-71E2-4236-8CF5-1C499BA3FF50"?>
<?else?>
<?error Invalid Platform ($(var.Platform))?>
<?endif?>
</Include>

View file

@ -6,6 +6,8 @@
param(
[string]$Configuration="Debug")
. "$PSScriptRoot\_common.ps1"
$ErrorActionPreference="Stop"
# Use a repo-local install directory (but not the artifacts directory because that gets cleaned a lot
@ -19,11 +21,14 @@ $env:PATH = "$env:DOTNET_INSTALL_DIR\cli\bin;$env:PATH"
if (!$env:DOTNET_BUILD_VERSION) {
# Get the timestamp of the most recent commit
$timestamp = git log -1 --format=%ct
$origin = New-Object -Type DateTime -ArgumentList 1970, 1, 1, 0, 0, 0, 0
$commitTime = $origin.AddSeconds($timestamp)
$LastCommitTimestamp = $commitTime.ToString("yyyyMMdd-HHmmss")
$commitTime = [timespan]::FromSeconds($timestamp)
$env:DOTNET_BUILD_VERSION = "0.0.1-alpha-$LastCommitTimestamp"
$majorVersion = 1
$minorVersion = 0
$buildnumber = $commitTime.Days
$revnumber = $commitTime.TotalSeconds
$env:DOTNET_BUILD_VERSION = "$majorVersion.$minorVersion.$buildnumber.$revnumber"
}
Write-Host -ForegroundColor Green "*** Building dotnet tools version $($env:DOTNET_BUILD_VERSION) - $Configuration ***"
@ -31,3 +36,6 @@ Write-Host -ForegroundColor Green "*** Building dotnet tools version $($env:DOTN
Write-Host -ForegroundColor Green "*** Packaging dotnet ***"
& "$PSScriptRoot\package\package.ps1"
Write-Host -ForegroundColor Green "*** Generating dotnet MSI ***"
& "$RepoRoot\packaging\windows\generatemsi.ps1" $Stage2Dir