2015-11-17 00:39:46 -08:00
# 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 (
2016-03-07 12:20:50 -08:00
[ Parameter ( Mandatory = $true ) ] [ string ] $inputDir ,
[ Parameter ( Mandatory = $true ) ] [ string ] $DotnetMSIOutput ,
2016-03-07 14:52:41 -08:00
[ Parameter ( Mandatory = $true ) ] [ string ] $WixRoot ,
2016-04-26 18:00:02 -07:00
[ Parameter ( Mandatory = $true ) ] [ string ] $ProductMoniker ,
2016-03-07 14:52:41 -08:00
[ Parameter ( Mandatory = $true ) ] [ string ] $DotnetMSIVersion ,
2016-04-15 12:11:10 -07:00
[ Parameter ( Mandatory = $true ) ] [ string ] $DotnetCLIDisplayVersion ,
[ Parameter ( Mandatory = $true ) ] [ string ] $DotnetCLINugetVersion ,
2016-03-24 18:05:14 -07:00
[ Parameter ( Mandatory = $true ) ] [ string ] $UpgradeCode ,
2018-07-10 16:24:50 -07:00
[ Parameter ( Mandatory = $true ) ] [ string ] $Architecture ,
[ Parameter ( Mandatory = $true ) ] [ string ] $StableFileIdForApphostTransform
2015-11-17 00:39:46 -08:00
)
2016-03-17 17:54:01 -07:00
. " $PSScriptRoot \..\..\..\scripts\common\_common.ps1 "
$RepoRoot = Convert-Path " $PSScriptRoot \..\..\.. "
2015-11-17 00:39:46 -08:00
$InstallFileswsx = " install-files.wxs "
$InstallFilesWixobj = " install-files.wixobj "
function RunHeat
{
2016-01-28 01:46:03 -08:00
$result = $true
pushd " $WixRoot "
2015-11-17 00:39:46 -08:00
2017-05-26 15:46:56 -07:00
Write-Output Running heat . .
2015-11-17 00:39:46 -08:00
2018-07-10 16:24:50 -07:00
# -t $StableFileIdForApphostTransform to avoid sign check baseline apphost.exe name changes every build. Sign check uses File Id in MSI as whitelist name.
# Template apphost.exe get a new "File Id" in msi different every time (since File Id is generated according to file
# path, and file path has version number)
# use XSLT tranform to match the file path contains "AppHostTemplate\apphost.exe" and give it the same ID all the time.
. \ heat . exe dir `" $inputDir `" -template fragment `
-sreg -gg `
-var var . DotnetSrc `
-cg InstallFiles `
-srd `
-dr DOTNETHOME `
-t $StableFileIdForApphostTransform `
-out $InstallFileswsx | Out-Host
2015-11-17 00:39:46 -08:00
if ( $LastExitCode -ne 0 )
{
$result = $false
2017-05-26 15:46:56 -07:00
Write-Output " Heat failed with exit code $LastExitCode . "
2015-11-17 00:39:46 -08:00
}
popd
return $result
}
function RunCandle
{
$result = $true
pushd " $WixRoot "
2017-05-26 15:46:56 -07:00
Write-Output Running candle . .
2016-03-17 17:54:01 -07:00
$AuthWsxRoot = Join-Path $RepoRoot " packaging\windows\clisdk "
2015-11-17 00:39:46 -08:00
2016-01-28 01:46:03 -08:00
. \ candle . exe -nologo `
-dDotnetSrc = " $inputDir " `
2017-06-21 15:15:21 -07:00
-dMicrosoftEula = " $RepoRoot \packaging\windows\clisdk\dummyeula.rtf " `
2016-04-26 18:00:02 -07:00
-dProductMoniker = " $ProductMoniker " `
2016-03-07 14:52:41 -08:00
-dBuildVersion = " $DotnetMSIVersion " `
2016-04-15 12:11:10 -07:00
-dDisplayVersion = " $DotnetCLIDisplayVersion " `
-dNugetVersion = " $DotnetCLINugetVersion " `
2016-03-24 18:05:14 -07:00
-dUpgradeCode = " $UpgradeCode " `
2016-03-07 14:52:41 -08:00
-arch " $Architecture " `
2015-11-17 20:32:02 -08:00
-ext WixDependencyExtension . dll `
" $AuthWsxRoot \dotnet.wxs " `
" $AuthWsxRoot \provider.wxs " `
" $AuthWsxRoot \registrykeys.wxs " `
2015-11-20 17:44:48 -08:00
$InstallFileswsx | Out-Host
2015-11-17 00:39:46 -08:00
if ( $LastExitCode -ne 0 )
{
$result = $false
2017-05-26 15:46:56 -07:00
Write-Output " Candle failed with exit code $LastExitCode . "
2015-11-17 00:39:46 -08:00
}
popd
return $result
}
function RunLight
{
$result = $true
pushd " $WixRoot "
2017-05-26 15:46:56 -07:00
Write-Output Running light . .
2016-01-28 01:46:03 -08:00
$CabCache = Join-Path $WixRoot " cabcache "
2016-03-17 17:54:01 -07:00
$AuthWsxRoot = Join-Path $RepoRoot " packaging\windows\clisdk "
2015-11-17 00:39:46 -08:00
2016-01-28 01:46:03 -08:00
. \ light . exe -nologo -ext WixUIExtension -ext WixDependencyExtension -ext WixUtilExtension `
2015-11-17 20:32:02 -08:00
-cultures: en-us `
dotnet . wixobj `
provider . wixobj `
registrykeys . wixobj `
$InstallFilesWixobj `
2016-01-28 01:46:03 -08:00
-b " $inputDir " `
-b " $AuthWsxRoot " `
-reusecab `
-cc " $CabCache " `
2015-11-20 17:44:48 -08:00
-out $DotnetMSIOutput | Out-Host
2015-11-17 00:39:46 -08:00
if ( $LastExitCode -ne 0 )
{
$result = $false
2017-05-26 15:46:56 -07:00
Write-Output " Light failed with exit code $LastExitCode . "
2015-11-17 00:39:46 -08:00
}
popd
return $result
}
if ( ! ( Test-Path $inputDir ) )
{
throw " $inputDir not found "
}
2017-05-26 15:46:56 -07:00
Write-Output " Creating dotnet MSI at $DotnetMSIOutput "
2015-11-17 00:39:46 -08:00
if ( [ string ] :: IsNullOrEmpty ( $WixRoot ) )
{
2015-12-28 11:47:21 -08:00
Exit -1
2015-11-17 00:39:46 -08:00
}
if ( -Not ( RunHeat ) )
2016-01-28 01:46:03 -08:00
{
2015-12-28 11:47:21 -08:00
Exit -1
2015-11-17 00:39:46 -08:00
}
if ( -Not ( RunCandle ) )
{
2015-12-28 11:47:21 -08:00
Exit -1
2015-11-17 00:39:46 -08:00
}
if ( -Not ( RunLight ) )
{
2015-12-28 11:47:21 -08:00
Exit -1
2015-11-17 00:39:46 -08:00
}
if ( ! ( Test-Path $DotnetMSIOutput ) )
{
throw " Unable to create the dotnet msi. "
2015-12-28 11:47:21 -08:00
Exit -1
2015-11-17 00:39:46 -08:00
}
2017-05-26 15:46:56 -07:00
Write-Output -ForegroundColor Green " Successfully created dotnet MSI - $DotnetMSIOutput "
2015-11-17 20:32:02 -08:00
exit $LastExitCode