2015-11-17 08:39:46 +00: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 20:20:50 +00:00
[ Parameter ( Mandatory = $true ) ] [ string ] $inputDir ,
[ Parameter ( Mandatory = $true ) ] [ string ] $DotnetMSIOutput ,
2016-03-07 22:52:41 +00:00
[ Parameter ( Mandatory = $true ) ] [ string ] $WixRoot ,
2016-04-27 01:00:02 +00:00
[ Parameter ( Mandatory = $true ) ] [ string ] $ProductMoniker ,
2016-03-07 22:52:41 +00:00
[ Parameter ( Mandatory = $true ) ] [ string ] $DotnetMSIVersion ,
2016-04-15 19:11:10 +00:00
[ Parameter ( Mandatory = $true ) ] [ string ] $DotnetCLIDisplayVersion ,
[ Parameter ( Mandatory = $true ) ] [ string ] $DotnetCLINugetVersion ,
2016-03-25 01:05:14 +00:00
[ Parameter ( Mandatory = $true ) ] [ string ] $UpgradeCode ,
2018-07-10 23:24:50 +00:00
[ Parameter ( Mandatory = $true ) ] [ string ] $Architecture ,
[ Parameter ( Mandatory = $true ) ] [ string ] $StableFileIdForApphostTransform
2015-11-17 08:39:46 +00:00
)
2016-03-18 00:54:01 +00:00
. " $PSScriptRoot \..\..\..\scripts\common\_common.ps1 "
$RepoRoot = Convert-Path " $PSScriptRoot \..\..\.. "
2015-11-17 08:39:46 +00:00
$InstallFileswsx = " install-files.wxs "
$InstallFilesWixobj = " install-files.wixobj "
function RunHeat
{
2016-01-28 09:46:03 +00:00
$result = $true
pushd " $WixRoot "
2015-11-17 08:39:46 +00:00
2017-05-26 22:46:56 +00:00
Write-Output Running heat . .
2015-11-17 08:39:46 +00:00
2018-07-10 23:24:50 +00: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 08:39:46 +00:00
if ( $LastExitCode -ne 0 )
{
$result = $false
2017-05-26 22:46:56 +00:00
Write-Output " Heat failed with exit code $LastExitCode . "
2015-11-17 08:39:46 +00:00
}
popd
return $result
}
function RunCandle
{
$result = $true
pushd " $WixRoot "
2017-05-26 22:46:56 +00:00
Write-Output Running candle . .
2016-03-18 00:54:01 +00:00
$AuthWsxRoot = Join-Path $RepoRoot " packaging\windows\clisdk "
2015-11-17 08:39:46 +00:00
2016-01-28 09:46:03 +00:00
. \ candle . exe -nologo `
-dDotnetSrc = " $inputDir " `
2017-06-21 22:15:21 +00:00
-dMicrosoftEula = " $RepoRoot \packaging\windows\clisdk\dummyeula.rtf " `
2016-04-27 01:00:02 +00:00
-dProductMoniker = " $ProductMoniker " `
2016-03-07 22:52:41 +00:00
-dBuildVersion = " $DotnetMSIVersion " `
2016-04-15 19:11:10 +00:00
-dDisplayVersion = " $DotnetCLIDisplayVersion " `
-dNugetVersion = " $DotnetCLINugetVersion " `
2016-03-25 01:05:14 +00:00
-dUpgradeCode = " $UpgradeCode " `
2016-03-07 22:52:41 +00:00
-arch " $Architecture " `
2015-11-18 04:32:02 +00:00
-ext WixDependencyExtension . dll `
" $AuthWsxRoot \dotnet.wxs " `
" $AuthWsxRoot \provider.wxs " `
" $AuthWsxRoot \registrykeys.wxs " `
2015-11-21 01:44:48 +00:00
$InstallFileswsx | Out-Host
2015-11-17 08:39:46 +00:00
if ( $LastExitCode -ne 0 )
{
$result = $false
2017-05-26 22:46:56 +00:00
Write-Output " Candle failed with exit code $LastExitCode . "
2015-11-17 08:39:46 +00:00
}
popd
return $result
}
function RunLight
{
$result = $true
pushd " $WixRoot "
2017-05-26 22:46:56 +00:00
Write-Output Running light . .
2016-01-28 09:46:03 +00:00
$CabCache = Join-Path $WixRoot " cabcache "
2016-03-18 00:54:01 +00:00
$AuthWsxRoot = Join-Path $RepoRoot " packaging\windows\clisdk "
2015-11-17 08:39:46 +00:00
2016-01-28 09:46:03 +00:00
. \ light . exe -nologo -ext WixUIExtension -ext WixDependencyExtension -ext WixUtilExtension `
2015-11-18 04:32:02 +00:00
-cultures: en-us `
dotnet . wixobj `
provider . wixobj `
registrykeys . wixobj `
$InstallFilesWixobj `
2016-01-28 09:46:03 +00:00
-b " $inputDir " `
-b " $AuthWsxRoot " `
-reusecab `
-cc " $CabCache " `
2015-11-21 01:44:48 +00:00
-out $DotnetMSIOutput | Out-Host
2015-11-17 08:39:46 +00:00
if ( $LastExitCode -ne 0 )
{
$result = $false
2017-05-26 22:46:56 +00:00
Write-Output " Light failed with exit code $LastExitCode . "
2015-11-17 08:39:46 +00:00
}
popd
return $result
}
if ( ! ( Test-Path $inputDir ) )
{
throw " $inputDir not found "
}
2017-05-26 22:46:56 +00:00
Write-Output " Creating dotnet MSI at $DotnetMSIOutput "
2015-11-17 08:39:46 +00:00
if ( [ string ] :: IsNullOrEmpty ( $WixRoot ) )
{
2015-12-28 19:47:21 +00:00
Exit -1
2015-11-17 08:39:46 +00:00
}
if ( -Not ( RunHeat ) )
2016-01-28 09:46:03 +00:00
{
2015-12-28 19:47:21 +00:00
Exit -1
2015-11-17 08:39:46 +00:00
}
if ( -Not ( RunCandle ) )
{
2015-12-28 19:47:21 +00:00
Exit -1
2015-11-17 08:39:46 +00:00
}
if ( -Not ( RunLight ) )
{
2015-12-28 19:47:21 +00:00
Exit -1
2015-11-17 08:39:46 +00:00
}
if ( ! ( Test-Path $DotnetMSIOutput ) )
{
throw " Unable to create the dotnet msi. "
2015-12-28 19:47:21 +00:00
Exit -1
2015-11-17 08:39:46 +00:00
}
2017-05-26 22:46:56 +00:00
Write-Output -ForegroundColor Green " Successfully created dotnet MSI - $DotnetMSIOutput "
2015-11-18 04:32:02 +00:00
exit $LastExitCode