@@ -25,7 +25,7 @@ function Start-PSPackage {
2525 [string ]$Name = " powershell" ,
2626
2727 # Ubuntu, CentOS, Fedora, macOS, and Windows packages are supported
28- [ValidateSet (" deb" , " osxpkg" , " rpm" , " msi" , " zip" , " nupkg" , " tar" , " tar-arm" , " tar-arm64" , " tar-alpine" , " fxdependent" )]
28+ [ValidateSet (" msix " , " deb" , " osxpkg" , " rpm" , " msi" , " zip" , " nupkg" , " tar" , " tar-arm" , " tar-arm64" , " tar-alpine" , " fxdependent" )]
2929 [string []]$Type ,
3030
3131 # Generate windows downlevel package
@@ -254,7 +254,7 @@ function Start-PSPackage {
254254 } elseif ($Environment.IsMacOS ) {
255255 " osxpkg" , " nupkg" , " tar"
256256 } elseif ($Environment.IsWindows ) {
257- " msi" , " nupkg"
257+ " msi" , " nupkg" , " msix "
258258 }
259259 Write-Warning " -Type was not specified, continuing with $Type !"
260260 }
@@ -335,6 +335,18 @@ function Start-PSPackage {
335335 New-MSIPackage @Arguments
336336 }
337337 }
338+ " msix" {
339+ $Arguments = @ {
340+ ProductNameSuffix = $NameSuffix
341+ ProductSourcePath = $Source
342+ ProductVersion = $Version
343+ Force = $Force
344+ }
345+
346+ if ($PSCmdlet.ShouldProcess (" Create MSIX Package" )) {
347+ New-MSIXPackage @Arguments
348+ }
349+ }
338350 ' nupkg' {
339351 $Arguments = @ {
340352 PackageNameSuffix = $NameSuffix
@@ -2726,6 +2738,107 @@ function New-MSIPackage
27262738 }
27272739}
27282740
2741+ <#
2742+ . Synopsis
2743+ Creates a Windows AppX MSIX package and assumes that the binaries are already built using 'Start-PSBuild'.
2744+ This only works on a Windows machine due to the usage of makeappx.exe.
2745+ . EXAMPLE
2746+ # This example shows how to produce a Debug-x64 installer for development purposes.
2747+ cd $RootPathOfPowerShellRepo
2748+ Import-Module .\build.psm1; Import-Module .\tools\packaging\packaging.psm1
2749+ New-MSIXPackage -Verbose -ProductSourcePath '.\src\powershell-win-core\bin\Debug\netcoreapp2.1\win7-x64\publish' -ProductTargetArchitecture x64 -ProductVersion '1.2.3'
2750+ #>
2751+ function New-MSIXPackage
2752+ {
2753+ [CmdletBinding (SupportsShouldProcess , ConfirmImpact = ' Low' )]
2754+ param (
2755+
2756+ # Name of the Product
2757+ [ValidateNotNullOrEmpty ()]
2758+ [string ] $ProductName = ' PowerShell' ,
2759+
2760+ # Suffix of the Name
2761+ [string ] $ProductNameSuffix ,
2762+
2763+ # Version of the Product
2764+ [Parameter (Mandatory = $true )]
2765+ [ValidateNotNullOrEmpty ()]
2766+ [string ] $ProductVersion ,
2767+
2768+ # Source Path to the Product Files - required to package the contents into an MSIX
2769+ [Parameter (Mandatory = $true )]
2770+ [ValidateNotNullOrEmpty ()]
2771+ [string ] $ProductSourcePath ,
2772+
2773+ # Force overwrite of package
2774+ [Switch ] $Force
2775+ )
2776+
2777+ $makeappx = Get-Command makeappx - CommandType Application - ErrorAction Ignore
2778+ if ($null -eq $makeappx ) {
2779+ # This is location in our dockerfile
2780+ $dockerPath = Join-Path $env: SystemDrive " makeappx"
2781+ if (Test-Path $dockerPath ) {
2782+ $makeappx = Get-ChildItem $dockerPath - Include makeappx.exe - Recurse | Select-Object - First 1
2783+ }
2784+
2785+ if ($null -eq $makeappx ) {
2786+ # Try to find in well known location
2787+ $makeappx = Get-ChildItem " ${env: ProgramFiles(x86)} \Windows Kits\10\bin\*\x64" - Include makeappx.exe - Recurse | Select-Object - First 1
2788+ if ($null -eq $makeappx ) {
2789+ throw " Could not locate makeappx.exe, make sure Windows 10 SDK is installed"
2790+ }
2791+ }
2792+ }
2793+
2794+ $makepri = Get-Item (Join-Path $makeappx.Directory " makepri.exe" ) - ErrorAction Stop
2795+
2796+ $ProductSemanticVersion = Get-PackageSemanticVersion - Version $ProductVersion
2797+ $productSemanticVersionWithName = $ProductName + ' -' + $ProductSemanticVersion
2798+ $packageName = $productSemanticVersionWithName
2799+ if ($ProductNameSuffix ) {
2800+ $packageName += " -$ProductNameSuffix "
2801+ }
2802+
2803+ $ProductVersion = Get-PackageVersionAsMajorMinorBuildRevision - Version $ProductVersion
2804+ if (([Version ]$ProductVersion ).Revision -eq -1 ) {
2805+ $ProductVersion += " .0"
2806+ }
2807+
2808+ # Appx manifest needs to be in root of source path, but the embedded version needs to be updated
2809+ $appxManifest = Get-Content " $RepoRoot \assets\AppxManifest.xml" - Raw
2810+ $appxManifest = $appxManifest.Replace (' $VERSION$' , $ProductVersion )
2811+ Set-Content - Path " $ProductSourcePath \AppxManifest.xml" - Value $appxManifest - Force
2812+ # Necessary image assets need to be in source assets folder
2813+ $assets = @ (
2814+ ' Square150x150Logo.png'
2815+ ' Square44x44Logo.png'
2816+ ' Square44x44Logo.targetsize-48.png'
2817+ ' Square44x44Logo.targetsize-48_altform-unplated.png'
2818+ ' StoreLogo.png'
2819+ )
2820+
2821+ if (! (Test-Path " $ProductSourcePath \assets" )) {
2822+ $null = New-Item - ItemType Directory - Path " $ProductSourcePath \assets"
2823+ }
2824+
2825+ $assets | ForEach-Object {
2826+ Copy-Item - Path " $RepoRoot \assets\$_ " - Destination " $ProductSourcePath \assets\"
2827+ }
2828+
2829+ if ($PSCmdlet.ShouldProcess (" Create .msix package?" )) {
2830+ Write-Verbose " Creating priconfig.xml" - Verbose
2831+ Start-NativeExecution - VerboseOutputOnError { & $makepri createconfig / o / cf (Join-Path $ProductSourcePath " priconfig.xml" ) / dq en- US }
2832+ Write-Verbose " Creating resources.pri" - Verbose
2833+ Push-Location $ProductSourcePath
2834+ Start-NativeExecution - VerboseOutputOnError { & $makepri new / v / o / pr $ProductSourcePath / cf (Join-Path $ProductSourcePath " priconfig.xml" ) }
2835+ Pop-Location
2836+ Write-Verbose " Creating msix package" - Verbose
2837+ Start-NativeExecution - VerboseOutputOnError { & $makeappx pack / o / v / h SHA256 / d $ProductSourcePath / p (Join-Path - Path $PWD - ChildPath " $packageName .msix" ) }
2838+ Write-Verbose " Created $packageName .msix" - Verbose
2839+ }
2840+ }
2841+
27292842# verify no files have been added or removed
27302843# if so, write an error with details
27312844function Test-FileWxs
0 commit comments