Files
terminal-microsoft/build/scripts/Create-AppxBundle.ps1
Tushar dc4ce1c096 Get Windows SDK path from Registry (#19042)
## Summary of the Pull Request
The Windows SDK path may not be the same on all PCs, especially when
Visual Studio (VS) is installed on a drive other than `C:/`. However, we
can read the correct path from the Registry, which this PR does.

## Validation Steps Performed
1. Install VS on `E:/`.
2. Build the solution and see it passes without erroring on accessing
`MakePri.exe`.
2026-06-25 13:11:38 -07:00

63 lines
1.8 KiB
PowerShell

Param(
[Parameter(Mandatory,
HelpMessage="Base name for input .appx files")]
[string]
$ProjectName,
[Parameter(Mandatory,
HelpMessage="Appx Bundle Version")]
[version]
$BundleVersion,
[Parameter(Mandatory,
HelpMessage="Path under which to locate appx/msix files")]
[string]
$InputPath,
[Parameter(Mandatory,
HelpMessage="Output Path")]
[string]
$OutputPath,
[Parameter(HelpMessage="Path to makeappx.exe")]
[ValidateScript({Test-Path $_ -Type Leaf})]
[string]
$MakeAppxPath
)
If (-not $MakeAppxPath) {
$winSdk10Root = $(Get-ItemPropertyValue -Path "HKLM:\Software\Microsoft\Windows Kits\Installed Roots" -Name "KitsRoot10")
$MakeAppxPath = "$winSdk10Root\bin\10.0.26100.0\x86\MakeAppx.exe"
}
If ($null -Eq (Get-Item $MakeAppxPath -EA:SilentlyContinue)) {
Write-Error "Could not find MakeAppx.exe at `"$MakeAppxPath`".`nMake sure that -MakeAppxPath points to a valid SDK."
Exit 1
}
# Enumerates a set of appx files beginning with a project name
# and generates a temporary file containing a bundle content map.
Function Create-AppxBundleMapping {
Param(
[Parameter(Mandatory)]
[string]
$InputPath,
[Parameter(Mandatory)]
[string]
$ProjectName
)
$lines = @("[Files]")
Get-ChildItem -Path:$InputPath -Recurse -Filter:*$ProjectName* -Include *.appx, *.msix | % {
$lines += ("`"{0}`" `"{1}`"" -f ($_.FullName, $_.Name))
}
$outputFile = New-TemporaryFile
$lines | Out-File -Encoding:ASCII $outputFile
$outputFile
}
$NewMapping = Create-AppxBundleMapping -InputPath:$InputPath -ProjectName:$ProjectName
& $MakeAppxPath bundle /v /bv $BundleVersion.ToString() /f $NewMapping.FullName /p $OutputPath