From 125daa71203ba94746cc737c60a5429a7da96131 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 11 Jan 2018 21:42:58 +0000 Subject: [PATCH 1/3] - 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 --- assets/Product.wxs | 4 ++-- build.psm1 | 24 ++++++++++++++++++------ tools/packaging/packaging.psm1 | 2 +- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/assets/Product.wxs b/assets/Product.wxs index d6381cd0073..30838d4c03c 100644 --- a/assets/Product.wxs +++ b/assets/Product.wxs @@ -5,7 +5,7 @@ - + @@ -25,7 +25,7 @@ - + diff --git a/build.psm1 b/build.psm1 index b17a39842ab..29c159910ef 100644 --- a/build.psm1 +++ b/build.psm1 @@ -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 $RootPathOfPowerShellCheckout + 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()] @@ -2070,8 +2080,9 @@ function New-MSIPackage [string] $ProductVersion, # Product Guid needs to change for every version to support SxS install + [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") diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index 35f3839e2fe..5fe582efc13 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -243,7 +243,7 @@ function Start-PSPackage { 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 + ProductCode = New-Guid ProductTargetArchitecture = $TargetArchitecture Force = $Force } From 7f3bfa7d3eae30c0401fdc0f33619ae9474556d9 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 12 Jan 2018 20:27:29 +0000 Subject: [PATCH 2/3] address PR comments (missing "product guid" -> "product code" renaming in comments) and use the word repo instead of checkout in comment to be more clear. --- build.psm1 | 4 ++-- tools/packaging/packaging.psm1 | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.psm1 b/build.psm1 index 29c159910ef..8733d1f0833 100644 --- a/build.psm1 +++ b/build.psm1 @@ -2058,7 +2058,7 @@ function Get-PackageVersionAsMajorMinorBuildRevision 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 $RootPathOfPowerShellCheckout + 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' #> @@ -2079,7 +2079,7 @@ function New-MSIPackage [ValidateNotNullOrEmpty()] [string] $ProductVersion, - # Product Guid needs to change for every version to support SxS install + # Product Code needs to change for every version to support SxS install [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] $ProductCode, diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index 5fe582efc13..ab4ecf65295 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -242,7 +242,7 @@ 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 + # Product Code needs to be unique for every PowerShell version to allow SxS install ProductCode = New-Guid ProductTargetArchitecture = $TargetArchitecture Force = $Force From 8e43d3f97cdf9982d69a5effc637cad661750108 Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 13 Jan 2018 00:34:07 +0000 Subject: [PATCH 3/3] address comments about the comments --- assets/Product.wxs | 2 +- build.psm1 | 2 +- tools/packaging/packaging.psm1 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/Product.wxs b/assets/Product.wxs index 30838d4c03c..63f42458a73 100644 --- a/assets/Product.wxs +++ b/assets/Product.wxs @@ -24,7 +24,7 @@ - + diff --git a/build.psm1 b/build.psm1 index 8733d1f0833..246e113615b 100644 --- a/build.psm1 +++ b/build.psm1 @@ -2079,7 +2079,7 @@ function New-MSIPackage [ValidateNotNullOrEmpty()] [string] $ProductVersion, - # Product Code 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] $ProductCode, diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index ab4ecf65295..b8cdb6cfe04 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -242,7 +242,7 @@ function Start-PSPackage { ProductVersion = $Version AssetsPath = "$PSScriptRoot\..\..\assets" LicenseFilePath = "$PSScriptRoot\..\..\assets\license.rtf" - # Product Code needs to be unique for every PowerShell version to allow SxS install + # 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