@@ -2039,193 +2039,6 @@ function script:Start-NativeExecution([scriptblock]$sb, [switch]$IgnoreExitcode)
2039
2039
}
2040
2040
}
2041
2041
2042
- # Builds coming out of this project can have version number as 'a.b.c' OR 'a.b.c-d-f'
2043
- # This function converts the above version into major.minor[.build[.revision]] format
2044
- function Get-PackageVersionAsMajorMinorBuildRevision
2045
- {
2046
- [CmdletBinding ()]
2047
- param (
20
10000
48
- # Version of the Package
2049
- [Parameter (Mandatory = $true )]
2050
- [ValidateNotNullOrEmpty ()]
2051
- [string ] $Version
2052
- )
2053
-
2054
- Write-Verbose " Extract the version in the form of major.minor[.build[.revision]] for $Version "
2055
- $packageVersionTokens = $Version.Split (' -' )
2056
- $packageVersion = ([regex ]::matches($Version , " \d+(\.\d+)+" ))[0 ].value
2057
-
2058
- if (1 -eq $packageVersionTokens.Count ) {
2059
- # In case the input is of the form a.b.c, add a '0' at the end for revision field
2060
- $packageVersion = $packageVersion + ' .0'
2061
- } elseif (1 -lt $packageVersionTokens.Count ) {
2062
- # We have all the four fields
2063
- $packageBuildTokens = ([regex ]::Matches($packageVersionTokens [1 ], " \d+" ))[0 ].value
2064
-
2065
- if ($packageBuildTokens )
2066
- {
2067
- $packageVersion = $packageVersion + ' .' + $packageBuildTokens
2068
- }
2069
- else
2070
- {
2071
- $packageVersion = $packageVersion
2072
- }
2073
- }
2074
-
2075
- $packageVersion
2076
- }
2077
-
2078
- <#
2079
- . Synopsis
2080
- Creates a Windows installer MSI package and assumes that the binaries are already built using 'Start-PSBuild'.
2081
- This only works on a Windows machine due to the usage of WiX.
2082
- . EXAMPLE
2083
- # This example shows how to produce a Debug-x64 installer for development purposes.
2084
- cd $RootPathOfPowerShellRepo
2085
- Import-Module .\build.psm1; Import-Module .\tools\packaging\packaging.psm1
2086
- New-MSIPackage -Verbose -ProductCode (New-Guid) -ProductSourcePath '.\src\powershell-win-core\bin\Debug\netcoreapp2.0\win7-x64\publish' -ProductTargetArchitecture x64 -ProductVersion '1.2.3'
2087
- #>
2088
- function New-MSIPackage
2089
- {
2090
- [CmdletBinding ()]
2091
- param (
2092
-
2093
- # Name of the Product
2094
- [ValidateNotNullOrEmpty ()]
2095
- [string ] $ProductName = ' PowerShell' ,
2096
-
2097
- # Suffix of the Name
2098
- [string ] $ProductNameSuffix ,
2099
-
2100
- # Version of the Product
2101
- [Parameter (Mandatory = $true )]
2102
- [ValidateNotNullOrEmpty ()]
2103
- [string ] $ProductVersion ,
2104
-
2105
- # The ProductCode property is a unique identifier for the particular product release
2106
- [Parameter (Mandatory = $true )]
2107
- [ValidateNotNullOrEmpty ()]
2108
- [string ] $ProductCode ,
2109
-
2110
- # Source Path to the Product Files - required to package the contents into an MSI
2111
- [Parameter (Mandatory = $true )]
2112
- [ValidateNotNullOrEmpty ()]
2113
- [string ] $ProductSourcePath ,
2114
-
2115
- # File describing the MSI Package creation semantics
2116
- [ValidateNotNullOrEmpty ()]
2117
- [ValidateScript ( {Test-Path $_ })]
2118
- [string ] $ProductWxsPath = " $PSScriptRoot \assets\Product.wxs" ,
2119
-
2120
- # Path to Assets folder containing artifacts such as icons, images
2121
- [ValidateNotNullOrEmpty ()]
2122
- [ValidateScript ( {Test-Path $_ })]
2123
- [string ] $AssetsPath = " $PSScriptRoot \assets" ,
2124
-
2125
- # Path to license.rtf file - for the EULA
2126
- [ValidateNotNullOrEmpty ()]
2127
- [ValidateScript ( {Test-Path $_ })]
2128
- [string ] $LicenseFilePath = " $PSScriptRoot \assets\license.rtf" ,
2129
-
2130
- # Architecture to use when creating the MSI
2131
- [Parameter (Mandatory = $true )]
2132
- [ValidateSet (" x86" , " x64" )]
2133
- [ValidateNotNullOrEmpty ()]
2134
- [string ] $ProductTargetArchitecture ,
2135
-
2136
- # Force overwrite of package
2137
- [Switch ] $Force
2138
- )
2139
-
2140
- # # AppVeyor base image might update the version for Wix. Hence, we should
2141
- # # not hard code version numbers.
2142
- $wixToolsetBinPath = " ${env: ProgramFiles(x86)} \WiX Toolset *\bin"
2143
-
2144
- Write-Verbose " Ensure Wix Toolset is present on the machine @ $wixToolsetBinPath "
2145
- if (-not (Test-Path $wixToolsetBinPath ))
2146
- {
2147
- throw " The latest version of Wix Toolset 3.11 is required to create MSI package. Please install it from https://github.com/wixtoolset/wix3/releases"
2148
- }
2149
-
2150
- # # Get the latest if multiple versions exist.
2151
- $wixToolsetBinPath = (Get-ChildItem $wixToolsetBinPath ).FullName | Sort-Object - Descending | Select-Object - First 1
2152
-
2153
- Write-Verbose " Initialize Wix executables - Heat.exe, Candle.exe, Light.exe"
2154
- $wixHeatExePath = Join-Path $wixToolsetBinPath " Heat.exe"
2155
- $wixCandleExePath = Join-Path $wixToolsetBinPath " Candle.exe"
2156
- $wixLightExePath = Join-Path $wixToolsetBinPath " Light.exe"
2157
-
2158
- $ProductSemanticVersion = Get-PackageSemanticVersion - Version $ProductVersion
2159
- $ProductVersion = Get-PackageVersionAsMajorMinorBuildRevision - Version $ProductVersion
2160
-
2161
- $assetsInSourcePath = Join-Path $ProductSourcePath ' assets'
2162
- New-Item $assetsInSourcePath - type directory - Force | Write-Verbose
2163
-
2164
- Write-Verbose " Place dependencies such as icons to $assetsInSourcePath "
2165
- Copy-Item " $AssetsPath \*.ico" $assetsInSourcePath - Force
2166
-
2167
- $productVersionWithName = $ProductName + ' _' + $ProductVersion
2168
- $productSemanticVersionWithName = $ProductName + ' -' + $ProductSemanticVersion
2169
-
2170
- Write-Verbose " Create MSI for Product $productSemanticVersionWithName "
2171
-
2172
- [Environment ]::SetEnvironmentVariable(" ProductSourcePath" , $ProductSourcePath , " Process" )
2173
- # These variables are used by Product.wxs in assets directory
2174
- [Environment ]::SetEnvironmentVariable(" ProductName" , $ProductName , " Process" )
2175
- [Environment ]::SetEnvironmentVariable(" ProductCode" , $ProductCode , " Process" )
2176
- [Environment ]::SetEnvironmentVariable(" ProductVersion" ,
10000
$ProductVersion , " Process" )
2177
- [Environment ]::SetEnvironmentVariable(" ProductSemanticVersion" , $ProductSemanticVersion , " Process" )
2178
- [Environment ]::SetEnvironmentVariable(" ProductVersionWithName" , $productVersionWithName , " Process" )
2179
- $ProductProgFilesDir = " ProgramFiles64Folder"
2180
- if ($ProductTargetArchitecture -eq " x86" )
2181
- {
2182
- $ProductProgFilesDir = " ProgramFilesFolder"
2183
- }
2184
- [Environment ]::SetEnvironmentVariable(" ProductProgFilesDir" , $ProductProgFilesDir , " Process" )
2185
-
2186
- $wixFragmentPath = Join-Path $env: Temp " Fragment.wxs"
2187
- $wixObjProductPath = Join-Path $env: Temp " Product.wixobj"
2188
- $wixObjFragmentPath = Join-Path $env: Temp " Fragment.wixobj"
2189
-
2190
- $packageName = $productSemanticVersionWithName
2191
- if ($ProductNameSuffix ) {
2192
- $packageName += " -$ProductNameSuffix "
2193
- }
2194
- $msiLocationPath = Join-Path $pwd " $packageName .msi"
2195
-
2196
- if (! $Force.IsPresent -and (Test-Path - Path $msiLocationPath ))
2197
- {
2198
- Write-Error - Message " Package already exists, use -Force to overwrite, path: $msiLocationPath " - ErrorAction Stop
2199
- }
2200
-
2201
- $WiXHeatLog = & $wixHeatExePath dir $ProductSourcePath - dr $productVersionWithName - cg $productVersionWithName - gg - sfrag - srd - scom - sreg - out $wixFragmentPath - var env.ProductSourcePath - v
2202
- $WiXCandleLog = & $wixCandleExePath " $ProductWxsPath " " $wixFragmentPath " - out (Join-Path " $env: Temp " " \\" ) - ext WixUIExtension - ext WixUtilExtension - arch $ProductTargetArchitecture - v
2203
- $WiXLightLog = & $wixLightExePath - out $msiLocationPath $wixObjProductPath $wixObjFragmentPath - ext WixUIExtension - ext WixUtilExtension - dWixUILicenseRtf= " $LicenseFilePath " - v
2204
-
2205
- Remove-Item - ErrorAction SilentlyContinue * .wixpdb - Force
2206
- Remove-Item - ErrorAction SilentlyContinue $wixFragmentPath - Force
2207
- Remove-Item - ErrorAction SilentlyContinue $wixObjProductPath - Force
2208
- Remove-Item - ErrorAction SilentlyContinue $wixObjFragmentPath - Force
2209
-
2210
- if (Test-Path $msiLocationPath )
2211
- {
2212
- Write-Verbose " You can find the MSI @ $msiLocationPath " - Verbose
2213
- $msiLocationPath
2214
- }
2215
- else
2216
- {
2217
- $WiXHeatLog | Out-String | Write-Verbose - Verbose
2218
- $WiXCandleLog | Out-String | Write-Verbose - Verbose
2219
- $WiXLightLog | Out-String | Write-Verbose - Verbose
2220
- $errorMessage = " Failed to create $msiLocationPath "
2221
- if ($null -ne $env: CI )
2222
- {
2223
- Add-AppveyorCompilationMessage $errorMessage - Category Error - FileName $MyInvocation.ScriptName - Line $MyInvocation.ScriptLineNumber
2224
- }
2225
- throw $errorMessage
2226
- }
2227
- }
2228
-
2229
2042
function Start-CrossGen {
2230
2043
[CmdletBinding ()]
2231
2044
param (
0 commit comments