mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
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
# Conflicts:
# assets/Product.wxs
This commit is contained in:
committed by
Travis Plunk
parent
379313918e
commit
4741be9237
+3
-3
@@ -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" ?>
|
||||
@@ -17,8 +17,8 @@
|
||||
<?define ProductVersionWithName = "$(var.ProductName)_$(var.ProductVersion)"?>
|
||||
<?define ProductSemanticVersionWithName = "$(var.ProductName)-$(env.ProductSemanticVersion)"?>
|
||||
<?define ProductProgFilesDir = "$(env.ProductProgFilesDir)" ?>
|
||||
<!-- 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
@@ -2061,6 +2061,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()]
|
||||
@@ -2078,9 +2088,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)]
|
||||
@@ -2089,17 +2100,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)]
|
||||
@@ -2146,7 +2158,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")
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user