Packaging: simplify building an installable package for Windows (#5871)

This is the continuation of PR 5499 that had to be abandoned due to a fatal merge conflict and I did not want to risk accidentally reverting recent fixes.

    Remove unnecessary/unused default for productGuid because it always gets a new Guid when being called from Start-PSPackage
    Add defaults for required files but also add extra path validation attribute
    Rename ProductGuid to ProductCode
This commit is contained in:
Christoph Bergmeister
2018-01-17 15:34:03 -08:00
committed by Travis Plunk
parent 76cbd0e1e7
commit d3a775da9a
3 changed files with 24 additions and 12 deletions
+3 -3
View File
@@ -5,7 +5,7 @@
<!-- TBD:Point to the actual release -->
<?define InfoURL="https://github.com/PowerShell/PowerShell" ?>
<?define ProductName = "$(env.ProductName)" ?>
<?define ProductGuid = "$(env.ProductGuid)" ?>
<?define ProductCode = "$(env.ProductCode)" ?>
<!-- UpgradeCode GUID MUST REMAIN SAME THROUGHOUT ALL VERSIONS, otherwise, updates won't occur. -->
<?if $(sys.BUILDARCH)=x64?>
<?define UpgradeCode = "31ab5147-9a97-4452-8443-d9709f0516e1" ?>
@@ -24,8 +24,8 @@
<!-- Explorer context submenu entries. The ampersand denotes the keyboard shortcut. -->
<?define ExplorerContextSubMenuDialogText = "Open &here"?>
<?define ExplorerContextSubMenuElevatedDialogText = "Open here as &Administrator"?>
<!-- The ProductCode is Product Id: http://wixtoolset.org/documentation/manual/v3/xsd/wix/product.html -->
<Product Id="$(var.ProductGuid)" Name="$(var.ProductSemanticVersionWithName)-$(sys.BUILDARCH)" Language="1033" Version="$(var.ProductVersion)" Manufacturer="Microsoft Corporation" UpgradeCode="$(var.UpgradeCode)">
<!-- The ProductCode is Product Id and needs to be unique for every PowerShell version to allow SxS install: http://wixtoolset.org/documentation/manual/v3/xsd/wix/product.html -->
<Product Id="$(var.ProductCode)" Name="$(var.ProductSemanticVersionWithName)-$(sys.BUILDARCH)" Language="1033" Version="$(var.ProductVersion)" Manufacturer="Microsoft Corporation" UpgradeCode="$(var.UpgradeCode)">
<!-- Properties About The Package -->
<Package Id="*" Keywords="Installer" Platform="$(sys.BUILDARCH)" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Description="PowerShell package" Comments="PowerShell for every system" />
<!-- Add PowerShell icon for executable -->
+19 -7
View File
@@ -2052,6 +2052,16 @@ function Get-PackageVersionAsMajorMinorBuildRevision
$packageVersion
}
<#
.Synopsis
Creates a Windows installer MSI package and assumes that the binaries are already built using 'Start-PSBuild'.
This only works on a Windows machine due to the usage of WiX.
.EXAMPLE
# This example shows how to produce a Debug-x64 installer for development purposes.
cd $RootPathOfPowerShellRepo
Import-Module .\build.psm1; Import-Module .\tools\packaging\packaging.psm1
New-MSIPackage -Verbose -ProductCode (New-Guid) -ProductSourcePath '.\src\powershell-win-core\bin\Debug\netcoreapp2.0\win7-x64\publish' -ProductTargetArchitecture x64 -ProductVersion '1.2.3'
#>
function New-MSIPackage
{
[CmdletBinding()]
@@ -2069,9 +2079,10 @@ function New-MSIPackage
[ValidateNotNullOrEmpty()]
[string] $ProductVersion,
# Product Guid needs to change for every version to support SxS install
# The ProductCode property is a unique identifier for the particular product release
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $ProductGuid = 'a5249933-73a1-4b10-8a4c-13c98bdc16fe',
[string] $ProductCode,
# Source Path to the Product Files - required to package the contents into an MSI
[Parameter(Mandatory = $true)]
@@ -2080,17 +2091,18 @@ function New-MSIPackage
# File describing the MSI Package creation semantics
[ValidateNotNullOrEmpty()]
[ValidateScript( {Test-Path $_})]
[string] $ProductWxsPath = "$PSScriptRoot\assets\Product.wxs",
# Path to Assets folder containing artifacts such as icons, images
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $AssetsPath,
[ValidateScript( {Test-Path $_})]
[string] $AssetsPath = "$PSScriptRoot\assets",
# Path to license.rtf file - for the EULA
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $LicenseFilePath,
[ValidateScript( {Test-Path $_})]
[string] $LicenseFilePath = "$PSScriptRoot\assets\license.rtf",
# Architecture to use when creating the MSI
[Parameter(Mandatory = $true)]
@@ -2137,7 +2149,7 @@ function New-MSIPackage
[Environment]::SetEnvironmentVariable("ProductSourcePath", $ProductSourcePath, "Process")
# These variables are used by Product.wxs in assets directory
[Environment]::SetEnvironmentVariable("ProductName", $ProductName, "Process")
[Environment]::SetEnvironmentVariable("ProductGuid", $ProductGuid, "Process")
[Environment]::SetEnvironmentVariable("ProductCode", $ProductCode, "Process")
[Environment]::SetEnvironmentVariable("ProductVersion", $ProductVersion, "Process")
[Environment]::SetEnvironmentVariable("ProductSemanticVersion", $ProductSemanticVersion, "Process")
[Environment]::SetEnvironmentVariable("ProductVersionWithName", $productVersionWithName, "Process")
+2 -2
View File
@@ -242,8 +242,8 @@ function Start-PSPackage {
ProductVersion = $Version
AssetsPath = "$PSScriptRoot\..\..\assets"
LicenseFilePath = "$PSScriptRoot\..\..\assets\license.rtf"
# Product Guid needs to be unique for every PowerShell version to allow SxS install
ProductGuid = New-Guid
# Product Code needs to be unique for every PowerShell version since it is a unique identifier for the particular product release
ProductCode = New-Guid
ProductTargetArchitecture = $TargetArchitecture
Force = $Force
}