First pass at building Windows MSI for the dotnet CLI repo.

- Use the heat tool to harvest the stage2 dir and create install-files.wxs
- dotnet.wxs contains the XML code which is constant across builds for an MSI.
- Use Candle and Light to generate the MSI from install-files.wxs and dotnet.wxs.

Default Install Location - %ProgramFiles%/dotnet.
Adds <InstallRoot>\bin %PATH%
Creates %DOTNET_HOME% pointing to <InstallRoot>
This commit is contained in:
Sridhar Periyasamy 2015-11-17 00:39:46 -08:00
parent 92857c7298
commit fb61e69a79
6 changed files with 210 additions and 0 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.Toolset.2015": "3.10.0.1503"
},
"frameworks": {
"dnxcore50": { }
}
}

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="{12897D7D-AC14-4971-AF57-157E8D327C79}" Language="1033" Manufacturer="Microsoft" Name="Dotnet CLI" UpgradeCode="{FCBF9710-A891-4FF5-8909-48E6EEC9180A}" Version="1.0.0.0">
<Package Compressed="yes" InstallerVersion="200" />
<WixVariable Id="WixUILicenseRtf" Value="$(var.MicrosoftEula)" />
<Property Id="WIXUI_INSTALLDIR" Value="DOTNETHOME"/>
<UIRef Id="WixUI_InstallDir" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="DOTNETHOME" Name="dotnet"/>
</Directory>
</Directory>
<DirectoryRef Id="TARGETDIR">
<Component Id="SETENVVARS" Guid="{E503A496-DE1B-4646-81D4-47213B4CCFAF}">
<Environment Id="PATH" Name="PATH" Value="[DOTNETHOME]bin" Permanent="no" Part="last" Action="set" System="no" />
<Environment Id="DOTNET_HOME" Name="DOTNET_HOME" Value="[DOTNETHOME]" Permanent="no" Part="all" Action="set" System="no" />
</Component>
</DirectoryRef>
<Feature Id="SetEnvVarsFeature" Level="1" Title="Set required env vars">
<ComponentRef Id="SETENVVARS" />
</Feature>
<Feature Id="DotnetFilesFeatures" Level="1" Title="Dotnet Files">
<ComponentGroupRef Id="InstallFiles" />
</Feature>
<Media Id="1" Cabinet="product.cab" EmbedCab="yes" />
</Product>
</Wix>

View file

@ -0,0 +1,142 @@
# 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 = Join-Path $env:TEMP WiX
.\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.Toolset.2015\3.10.0.1503\tools\wix
}
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..
.\candle.exe -dDotnetSrc="$inputDir" -dMicrosoftEula="$RepoRoot\packaging\osx\resources\en.lproj\eula.rtf" "$RepoRoot\packaging\windows\dotnet.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 -cultures:en-us dotnet.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))
{
Write-Host Fooooobar
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"
return 0

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
@ -31,3 +33,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