mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-12 00:07:24 -06:00
unpackaged: allow building an unpackaged distribution from layout (#15133)
This PR adds a convenience feature to New-UnpackagedTerminalDistribution
that produces an unpackaged layout from an already-unpacked AppX, like
the one Visual Studio registers.
```powershell
New-UnpackagedTerminalDistribution `
-TerminalLayout path\to\bin\x64\Debug\AppX `
-XamlAppX path\to\xaml\2.8.appx
```
The output item when you build an unpackaged layout is the temp folder
in which the distribution was built. It will not make a zip file for
you.
This commit is contained in:
parent
2c165438ef
commit
2fd33ba510
@ -1,21 +1,28 @@
|
|||||||
|
[CmdletBinding(DefaultParameterSetName = 'AppX')]
|
||||||
Param(
|
Param(
|
||||||
[Parameter(Mandatory,
|
[Parameter(Mandatory, HelpMessage="Path to Terminal AppX", ParameterSetName = 'AppX')]
|
||||||
HelpMessage="Path to Terminal AppX")]
|
|
||||||
[ValidateScript({Test-Path $_ -Type Leaf})]
|
[ValidateScript({Test-Path $_ -Type Leaf})]
|
||||||
[string]
|
[string]
|
||||||
$TerminalAppX,
|
$TerminalAppX,
|
||||||
|
|
||||||
[Parameter(Mandatory,
|
[Parameter(Mandatory, HelpMessage="Path to Terminal Layout Deployment", ParameterSetName='Layout')]
|
||||||
HelpMessage="Path to Xaml AppX")]
|
[ValidateScript({Test-Path $_ -Type Container})]
|
||||||
|
[string]
|
||||||
|
$TerminalLayout,
|
||||||
|
|
||||||
|
[Parameter(Mandatory, HelpMessage="Path to Xaml AppX", ParameterSetName='AppX')]
|
||||||
|
[Parameter(Mandatory, HelpMessage="Path to Xaml AppX", ParameterSetName='Layout')]
|
||||||
[ValidateScript({Test-Path $_ -Type Leaf})]
|
[ValidateScript({Test-Path $_ -Type Leaf})]
|
||||||
[string]
|
[string]
|
||||||
$XamlAppX,
|
$XamlAppX,
|
||||||
|
|
||||||
[Parameter(HelpMessage="Output Directory")]
|
[Parameter(HelpMessage="Output Directory", ParameterSetName='AppX')]
|
||||||
|
[Parameter(HelpMessage="Output Directory", ParameterSetName='Layout')]
|
||||||
[string]
|
[string]
|
||||||
$Destination = ".",
|
$Destination = ".",
|
||||||
|
|
||||||
[Parameter(HelpMessage="Path to makeappx.exe")]
|
[Parameter(HelpMessage="Path to makeappx.exe", ParameterSetName='AppX')]
|
||||||
|
[Parameter(HelpMessage="Path to makeappx.exe", ParameterSetName='Layout')]
|
||||||
[ValidateScript({Test-Path $_ -Type Leaf})]
|
[ValidateScript({Test-Path $_ -Type Leaf})]
|
||||||
[string]
|
[string]
|
||||||
$MakeAppxPath = "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64\MakeAppx.exe"
|
$MakeAppxPath = "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64\MakeAppx.exe"
|
||||||
@ -36,14 +43,17 @@ $tempDir = Join-Path ([System.IO.Path]::GetTempPath()) "tmp$([Convert]::ToString
|
|||||||
New-Item -ItemType Directory -Path $tempDir | Out-Null
|
New-Item -ItemType Directory -Path $tempDir | Out-Null
|
||||||
|
|
||||||
$XamlAppX = Get-Item $XamlAppX | Select-Object -Expand FullName
|
$XamlAppX = Get-Item $XamlAppX | Select-Object -Expand FullName
|
||||||
$TerminalAppX = Get-Item $TerminalAppX | Select-Object -Expand FullName
|
|
||||||
|
|
||||||
########
|
########
|
||||||
# Reading the AppX Manifest for preliminary info
|
# Reading the AppX Manifest for preliminary info
|
||||||
########
|
########
|
||||||
|
|
||||||
$appxManifestPath = Join-Path $tempDir AppxManifest.xml
|
If ($TerminalAppX) {
|
||||||
& tar.exe -x -f "$TerminalAppX" -C $tempDir AppxManifest.xml
|
$appxManifestPath = Join-Path $tempDir AppxManifest.xml
|
||||||
|
& tar.exe -x -f "$TerminalAppX" -C $tempDir AppxManifest.xml
|
||||||
|
} ElseIf($TerminalLayout) {
|
||||||
|
$appxManifestPath = Join-Path $TerminalLayout AppxManifest.xml
|
||||||
|
}
|
||||||
$manifest = [xml](Get-Content $appxManifestPath)
|
$manifest = [xml](Get-Content $appxManifestPath)
|
||||||
$pfn = $manifest.Package.Identity.Name
|
$pfn = $manifest.Package.Identity.Name
|
||||||
$version = $manifest.Package.Identity.Version
|
$version = $manifest.Package.Identity.Version
|
||||||
@ -57,13 +67,20 @@ $terminalDir = "terminal-{0}" -f ($version)
|
|||||||
########
|
########
|
||||||
|
|
||||||
$terminalAppPath = Join-Path $tempdir $terminalDir
|
$terminalAppPath = Join-Path $tempdir $terminalDir
|
||||||
$xamlAppPath = Join-Path $tempdir "xaml"
|
|
||||||
New-Item -ItemType Directory -Path $terminalAppPath | Out-Null
|
If ($TerminalAppX) {
|
||||||
New-Item -ItemType Directory -Path $xamlAppPath | Out-Null
|
$TerminalAppX = Get-Item $TerminalAppX | Select-Object -Expand FullName
|
||||||
& $MakeAppxPath unpack /p $TerminalAppX /d $terminalAppPath /o | Out-Null
|
New-Item -ItemType Directory -Path $terminalAppPath | Out-Null
|
||||||
If ($LASTEXITCODE -Ne 0) {
|
& $MakeAppxPath unpack /p $TerminalAppX /d $terminalAppPath /o | Out-Null
|
||||||
Throw "Unpacking $TerminalAppX failed"
|
If ($LASTEXITCODE -Ne 0) {
|
||||||
|
Throw "Unpacking $TerminalAppX failed"
|
||||||
|
}
|
||||||
|
} ElseIf ($TerminalLayout) {
|
||||||
|
Copy-Item -Recurse -Path $TerminalLayout -Destination $terminalAppPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$xamlAppPath = Join-Path $tempdir "xaml"
|
||||||
|
New-Item -ItemType Directory -Path $xamlAppPath | Out-Null
|
||||||
& $MakeAppxPath unpack /p $XamlAppX /d $xamlAppPath /o | Out-Null
|
& $MakeAppxPath unpack /p $XamlAppX /d $xamlAppPath /o | Out-Null
|
||||||
If ($LASTEXITCODE -Ne 0) {
|
If ($LASTEXITCODE -Ne 0) {
|
||||||
Throw "Unpacking $XamlAppX failed"
|
Throw "Unpacking $XamlAppX failed"
|
||||||
@ -105,13 +122,19 @@ $finalTerminalPriFile = Join-Path $terminalAppPath "resources.pri"
|
|||||||
-TerminalRoot $terminalAppPath `
|
-TerminalRoot $terminalAppPath `
|
||||||
-XamlRoot $xamlAppPath `
|
-XamlRoot $xamlAppPath `
|
||||||
-OutputPath $finalTerminalPriFile `
|
-OutputPath $finalTerminalPriFile `
|
||||||
-Verbose:$Verbose
|
-Verbose:$Verbose | Out-Host
|
||||||
|
|
||||||
########
|
########
|
||||||
# Packaging
|
# Packaging
|
||||||
########
|
########
|
||||||
|
|
||||||
New-Item -ItemType Directory -Path $Destination -ErrorAction:SilentlyContinue | Out-Null
|
If ($PSCmdlet.ParameterSetName -Eq "AppX") {
|
||||||
$outputZip = (Join-Path $Destination ("{0}.zip" -f ($distributionName)))
|
# We only produce a ZIP when we're combining two AppX directories.
|
||||||
& tar -c --format=zip -f $outputZip -C $tempDir $terminalDir
|
New-Item -ItemType Directory -Path $Destination -ErrorAction:SilentlyContinue | Out-Null
|
||||||
Get-Item $outputZip
|
$outputZip = (Join-Path $Destination ("{0}.zip" -f ($distributionName)))
|
||||||
|
& tar -c --format=zip -f $outputZip -C $tempDir $terminalDir
|
||||||
|
Remove-Item -Recurse -Force $tempDir -EA:SilentlyContinue
|
||||||
|
Get-Item $outputZip
|
||||||
|
} ElseIf ($PSCmdlet.ParameterSetName -Eq "Layout") {
|
||||||
|
Get-Item $terminalAppPath
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user