Skip to content

Commit 81ebe1e

Browse files
Generate MSI for win-arm64 installer (#20516) (#23910)
1 parent 3b26088 commit 81ebe1e

7 files changed

Lines changed: 110 additions & 16 deletions

File tree

assets/wix/Product.wxs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@
2020
<?else?>
2121
<?define UpgradeCode = $(var.UpgradeCodeRelease)?>
2222
<?endif?>
23+
<?elseif $(sys.BUILDARCH) = "ARM64"?>
24+
<?define ExplorerContextMenuDialogText = "&$(var.ProductName) $(var.SimpleProductVersion) ($(sys.BUILDARCH))"?>
25+
<?define UpgradeCodePreview = "f064cf16-97b7-4550-b392-ce0f4a6823a3"?>
26+
<?define UpgradeCodeRelease = "75c68ab2-09d8-46b8-b697-d829bdd4c94f"?>
27+
<?if $(var.IsPreview)=True?>
28+
<?define UpgradeCode = $(var.UpgradeCodePreview)?>
29+
<?else?>
30+
<?define UpgradeCode = $(var.UpgradeCodeRelease)?>
31+
<?endif?>
2332
<?else?>
2433
<?define ExplorerContextMenuDialogText = "&$(var.ProductName) $(var.SimpleProductVersion) ($(sys.BUILDARCH))"?>
2534
<?define UpgradeCodePreview = "86abcfbd-1ccc-4a88-b8b2-0facfde29094"?>

assets/wix/bundle.wxs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99
<?else?>
1010
<?define UpgradeCode = $(var.UpgradeCodeRelease)?>
1111
<?endif?>
12+
<?elseif $(sys.BUILDARCH) = "ARM64"?>
13+
<?define ExplorerContextMenuDialogText = "&$(var.ProductName) $(var.SimpleProductVersion) ($(sys.BUILDARCH))"?>
14+
<?define UpgradeCodePreview = "499e9123-48aa-41df-aa20-6f4d28b54722"?>
15+
<?define UpgradeCodeRelease = "4cc0e36a-17db-4c84-b4f4-560a11e7ddb6"?>
16+
<?if $(var.IsPreview)=True?>
17+
<?define UpgradeCode = $(var.UpgradeCodePreview)?>
18+
<?else?>
19+
<?define UpgradeCode = $(var.UpgradeCodeRelease)?>
20+
<?endif?>
1221
<?else?>
1322
<?define UpgradeCodePreview = "4A699A9C-E904-4024-BCD2-44E098A8C6BD"?>
1423
<?define UpgradeCodeRelease = "ED46CB02-64B3-43FD-A63E-6CF269D8C21C"?>

tools/ci.psm1

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,11 @@ function Invoke-CIFinish
541541
}
542542
'win-arm.*' {
543543
$runPackageTest = $false
544-
$packageTypes = 'zip', 'zip-pdb', 'msix'
544+
$packageTypes = 'msi', 'zip', 'zip-pdb', 'msix'
545545
}
546546
}
547+
548+
Install-WixArmZip
547549
$packages = Start-PSPackage -Type $packageTypes -ReleaseTag $preReleaseVersion -SkipReleaseChecks -WindowsRuntime $Runtime
548550

549551
foreach ($package in $packages) {
@@ -620,6 +622,62 @@ function Invoke-CIFinish
620622
}
621623
}
622624

625+
function Install-WixArmZip
626+
{
627+
# cleanup previous install
628+
if((Test-Path "${env:ProgramFiles(x86)}\Arm Support WiX Toolset xcopy")) {
629+
Remove-Item "${env:ProgramFiles(x86)}\Arm Support WiX Toolset xcopy" -Recurse -Force
630+
}
631+
632+
# This URI is for wix 3.14 which supports generating msi for arm architecures.
633+
$wixUriArmSupport = 'https://aka.ms/ps-wix-3-14-zip'
634+
$zipArmSupport = "$env:TEMP\wixArmSupport.zip"
635+
$targetRoot = "${env:ProgramFiles(x86)}\Arm Support WiX Toolset xcopy"
636+
Invoke-RestMethod -Uri $wixUriArmSupport -OutFile $zipArmSupport
637+
638+
$binPath = Join-Path -Path $targetRoot -ChildPath 'bin'
639+
Write-Verbose "Expanding $zipArmSupport to $binPath ..." -Verbose
640+
Expand-Archive -Path $zipArmSupport -DestinationPath $binPath -Force
641+
$docExpandPath = Join-Path -Path $binPath -ChildPath 'doc'
642+
$sdkExpandPath = Join-Path -Path $binPath -ChildPath 'sdk'
643+
$docTargetPath = Join-Path -Path $targetRoot -ChildPath 'doc'
644+
$sdkTargetPath = Join-Path -Path $targetRoot -ChildPath 'sdk'
645+
Write-Verbose "Fixing folder structure ..." -Verbose
646+
Move-Item -Path $docExpandPath -Destination $docTargetPath
647+
Move-Item -Path $sdkExpandPath -Destination $sdkTargetPath
648+
Set-Path -Append -Path $binPath
649+
Write-Verbose "Done installing WIX for arm!"
650+
}
651+
652+
function Set-Path
653+
{
654+
param
655+
(
656+
[Parameter(Mandatory)]
657+
[string]
658+
$Path,
659+
660+
[Parameter(Mandatory)]
661+
[switch]
662+
$Append
663+
)
664+
665+
$machinePathString = [System.Environment]::GetEnvironmentVariable('path',[System.EnvironmentVariableTarget]::Machine)
666+
$machinePath = $machinePathString -split ';'
667+
668+
if($machinePath -inotcontains $path)
669+
{
670+
$newPath = "$machinePathString;$path"
671+
Write-Verbose "Adding $path to path..." -Verbose
672+
[System.Environment]::SetEnvironmentVariable('path',$newPath,[System.EnvironmentVariableTarget]::Machine)
673+
Write-Verbose "Added $path to path." -Verbose
674+
}
675+
else
676+
{
677+
Write-Verbose "$path already in path." -Verbose
678+
}
679+
}
680+
623681
# Bootstrap script for Linux and macOS
624682
function Invoke-BootstrapStage
625683
{

tools/packaging/packaging.psm1

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,12 @@ function Start-PSPackage {
486486
$TargetArchitecture = "x86"
487487
$r2rArchitecture = "i386"
488488
}
489+
elseif ($Runtime -match "-arm64")
490+
{
491+
$TargetArchitecture = "arm64"
492+
$r2rArchitecture = "arm64"
493+
}
494+
489495
Write-Verbose "TargetArchitecture = $TargetArchitecture" -Verbose
490496

491497
$Arguments = @{
@@ -3279,12 +3285,23 @@ function Get-NugetSemanticVersion
32793285
# Get the paths to various WiX tools
32803286
function Get-WixPath
32813287
{
3282-
$wixToolsetBinPath = "${env:ProgramFiles(x86)}\WiX Toolset *\bin"
3288+
[CmdletBinding()]
3289+
param (
3290+
[bool] $IsProductArchitectureArm = $false
3291+
)
32833292

3284-
Write-Verbose "Ensure Wix Toolset is present on the machine @ $wixToolsetBinPath"
3293+
$wixToolsetBinPath = $IsProductArchitectureArm ? "${env:ProgramFiles(x86)}\Arm Support WiX Toolset *\bin" : "${env:ProgramFiles(x86)}\WiX Toolset *\bin"
3294+
3295+
Write-Verbose -Verbose "Ensure Wix Toolset is present on the machine @ $wixToolsetBinPath"
32853296
if (-not (Test-Path $wixToolsetBinPath))
32863297
{
3287-
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"
3298+
if (!$IsProductArchitectureArm)
3299+
{
3300+
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"
3301+
}
3302+
else {
3303+
throw "The latest version of Wix Toolset 3.14 is required to create MSI package for arm. Please install it from https://aka.ms/ps-wix-3-14-zip"
3304+
}
32883305
}
32893306

32903307
## Get the latest if multiple versions exist.
@@ -3308,7 +3325,6 @@ function Get-WixPath
33083325
WixLightExePath = $wixLightExePath
33093326
WixInsigniaExePath = $wixInsigniaExePath
33103327
}
3311-
33123328
}
33133329

33143330
<#
@@ -3360,7 +3376,7 @@ function New-MSIPackage
33603376

33613377
# Architecture to use when creating the MSI
33623378
[Parameter(Mandatory = $true)]
3363-
[ValidateSet("x86", "x64")]
3379+
[ValidateSet("x86", "x64", "arm64")]
33643380
[ValidateNotNullOrEmpty()]
33653381
[string] $ProductTargetArchitecture,
33663382

@@ -3370,7 +3386,7 @@ function New-MSIPackage
33703386
[string] $CurrentLocation = (Get-Location)
33713387
)
33723388

3373-
$wixPaths = Get-WixPath
3389+
$wixPaths = Get-WixPath -IsProductArchitectureArm ($ProductTargetArchitecture -eq "arm64")
33743390

33753391
$windowsNames = Get-WindowsNames -ProductName $ProductName -ProductNameSuffix $ProductNameSuffix -ProductVersion $ProductVersion
33763392
$productSemanticVersionWithName = $windowsNames.ProductSemanticVersionWithName
@@ -3408,6 +3424,11 @@ function New-MSIPackage
34083424
$fileArchitecture = 'x86'
34093425
$ProductProgFilesDir = "ProgramFilesFolder"
34103426
}
3427+
elseif ($ProductTargetArchitecture -eq "arm64")
3428+
{
3429+
$fileArchitecture = 'arm64'
3430+
$ProductProgFilesDir = "ProgramFiles64Folder"
3431+
}
34113432

34123433
$wixFragmentPath = Join-Path $env:Temp "Fragment.wxs"
34133434

@@ -3522,7 +3543,7 @@ function New-ExePackage {
35223543

35233544
# Architecture to use when creating the MSI
35243545
[Parameter(Mandatory = $true)]
3525-
[ValidateSet("x86", "x64")]
3546+
[ValidateSet("x86", "x64", "arm64")]
35263547
[ValidateNotNullOrEmpty()]
35273548
[string] $ProductTargetArchitecture,
35283549

@@ -3644,7 +3665,7 @@ function Start-MsiBuild {
36443665

36453666
$outDir = $env:Temp
36463667

3647-
$wixPaths = Get-WixPath
3668+
$wixPaths = Get-WixPath -IsProductArchitectureArm ($ProductTargetArchitecture -eq "arm64")
36483669

36493670
$extensionArgs = @()
36503671
foreach ($extensionName in $Extension) {

tools/releaseBuild/Images/microsoft_powershell_windowsservercore/PowerShellPackage.ps1

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,8 @@ try
153153

154154
if (!$Symbols -and $Runtime -notlike 'fxdependent*' -and !$ForMinimalSize)
155155
{
156-
if ($Runtime -notmatch 'arm')
157-
{
158-
Write-Verbose "Starting powershell packaging(msi)..." -Verbose
159-
Start-PSPackage @pspackageParams @releaseTagParam
160-
}
156+
Write-Verbose "Starting powershell packaging(msi)..." -Verbose
157+
Start-PSPackage @pspackageParams @releaseTagParam
161158

162159
$pspackageParams['Type']='msix'
163160
Write-Verbose "Starting powershell packaging(msix)..." -Verbose

tools/releaseBuild/azureDevOps/templates/windows-package-signing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ jobs:
9999
parameters:
100100
architecture: arm64
101101
version: $(version)
102-
msi: no
102+
msi: yes
103103

104104
- template: upload.yml
105105
parameters:

tools/releaseBuild/azureDevOps/templates/windows-packaging.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ jobs:
270270
displayName: Upload unsigned packages
271271
retryCountOnTaskFailure: 2
272272
273-
- ${{ if and(ne(variables['BuildConfiguration'],'minSize'), in(variables['Architecture'], 'x64', 'x86')) }}:
273+
- ${{ if and(ne(variables['BuildConfiguration'],'minSize'), in(variables['Architecture'], 'x64', 'x86', 'arm64')) }}:
274274
- template: EsrpSign.yml@ComplianceRepo
275275
parameters:
276276
buildOutputPath: $(System.ArtifactsDirectory)\pkgSigned

0 commit comments

Comments
 (0)