Enable building of msix package (#9289)

Add support in packaging.psm1 to produce a .msix AppX package.  Update the docker image to use the new msix package type.  Update the associated yml files so AzDevOps performs the build.

## PR Context

Enable publishing PSCore6 to Microsoft Store
This commit is contained in:
Steve Lee 2019-04-15 17:07:15 -07:00 committed by Travis Plunk
parent 23451ac32f
commit 73114ee36c
13 changed files with 208 additions and 8 deletions

1
.gitignore vendored
View File

@ -34,6 +34,7 @@ dotnet-uninstall-debian-packages.sh
*.exe
*.msi
*.appx
*.msix
# Ignore binaries and symbols
*.pdb

49
assets/AppxManifest.xml Normal file
View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<Package IgnorableNamespaces="uap mp rescap desktop6"
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
xmlns:desktop6="http://schemas.microsoft.com/appx/manifest/desktop/windows10/6"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities">
<Identity Name="Microsoft.PowerShell" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" Version="$VERSION$" />
<Properties>
<DisplayName>PowerShell Core 6</DisplayName>
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
<Logo>assets\StoreLogo.png</Logo>
<desktop6:RegistryWriteVirtualization>disabled</desktop6:RegistryWriteVirtualization>
<desktop6:FileSystemWriteVirtualization>disabled</desktop6:FileSystemWriteVirtualization>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.17763.0" />
</Dependencies>
<Resources>
<Resource Language="en-US"/>
</Resources>
<Applications>
<Application Id="App" Executable="pwsh.exe" EntryPoint="Windows.FullTrustApplication">
<Extensions>
<uap3:Extension Category="windows.appExecutionAlias" EntryPoint="Windows.FullTrustApplication" Executable="pwsh.exe">
<uap3:AppExecutionAlias>
<desktop:ExecutionAlias Alias="pwsh.exe" />
</uap3:AppExecutionAlias>
</uap3:Extension>
</Extensions>
<uap:VisualElements DisplayName="PowerShell Core 6" Description="PowerShell is an automation and configuration management platform. It consists of a cross-platform (Windows, Linux, and macOS) command-line shell and associated scripting language." BackgroundColor="transparent" Square150x150Logo="assets\Square150x150Logo.png" Square44x44Logo="assets\Square44x44Logo.png">
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="runFullTrust" />
<rescap:Capability Name="unvirtualizedResources" />
</Capabilities>
</Package>

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
assets/Square44x44Logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
assets/StoreLogo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -25,7 +25,7 @@ function Start-PSPackage {
[string]$Name = "powershell",
# Ubuntu, CentOS, Fedora, macOS, and Windows packages are supported
[ValidateSet("deb", "osxpkg", "rpm", "msi", "zip", "nupkg", "tar", "tar-arm", "tar-arm64", "tar-alpine", "fxdependent")]
[ValidateSet("msix", "deb", "osxpkg", "rpm", "msi", "zip", "nupkg", "tar", "tar-arm", "tar-arm64", "tar-alpine", "fxdependent")]
[string[]]$Type,
# Generate windows downlevel package
@ -254,7 +254,7 @@ function Start-PSPackage {
} elseif ($Environment.IsMacOS) {
"osxpkg", "nupkg", "tar"
} elseif ($Environment.IsWindows) {
"msi", "nupkg"
"msi", "nupkg", "msix"
}
Write-Warning "-Type was not specified, continuing with $Type!"
}
@ -335,6 +335,18 @@ function Start-PSPackage {
New-MSIPackage @Arguments
}
}
"msix" {
$Arguments = @{
ProductNameSuffix = $NameSuffix
ProductSourcePath = $Source
ProductVersion = $Version
Force = $Force
}
if ($PSCmdlet.ShouldProcess("Create MSIX Package")) {
New-MSIXPackage @Arguments
}
}
'nupkg' {
$Arguments = @{
PackageNameSuffix = $NameSuffix
@ -2726,6 +2738,107 @@ function New-MSIPackage
}
}
<#
.Synopsis
Creates a Windows AppX MSIX package and assumes that the binaries are already built using 'Start-PSBuild'.
This only works on a Windows machine due to the usage of makeappx.exe.
.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-MSIXPackage -Verbose -ProductSourcePath '.\src\powershell-win-core\bin\Debug\netcoreapp2.1\win7-x64\publish' -ProductTargetArchitecture x64 -ProductVersion '1.2.3'
#>
function New-MSIXPackage
{
[CmdletBinding(SupportsShouldProcess, ConfirmImpact='Low')]
param (
# Name of the Product
[ValidateNotNullOrEmpty()]
[string] $ProductName = 'PowerShell',
# Suffix of the Name
[string] $ProductNameSuffix,
# Version of the Product
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $ProductVersion,
# Source Path to the Product Files - required to package the contents into an MSIX
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $ProductSourcePath,
# Force overwrite of package
[Switch] $Force
)
$makeappx = Get-Command makeappx -CommandType Application -ErrorAction Ignore
if ($null -eq $makeappx) {
# This is location in our dockerfile
$dockerPath = Join-Path $env:SystemDrive "makeappx"
if (Test-Path $dockerPath) {
$makeappx = Get-ChildItem $dockerPath -Include makeappx.exe -Recurse | Select-Object -First 1
}
if ($null -eq $makeappx) {
# Try to find in well known location
$makeappx = Get-ChildItem "${env:ProgramFiles(x86)}\Windows Kits\10\bin\*\x64" -Include makeappx.exe -Recurse | Select-Object -First 1
if ($null -eq $makeappx) {
throw "Could not locate makeappx.exe, make sure Windows 10 SDK is installed"
}
}
}
$makepri = Get-Item (Join-Path $makeappx.Directory "makepri.exe") -ErrorAction Stop
$ProductSemanticVersion = Get-PackageSemanticVersion -Version $ProductVersion
$productSemanticVersionWithName = $ProductName + '-' + $ProductSemanticVersion
$packageName = $productSemanticVersionWithName
if ($ProductNameSuffix) {
$packageName += "-$ProductNameSuffix"
}
$ProductVersion = Get-PackageVersionAsMajorMinorBuildRevision -Version $ProductVersion
if (([Version]$ProductVersion).Revision -eq -1) {
$ProductVersion += ".0"
}
# Appx manifest needs to be in root of source path, but the embedded version needs to be updated
$appxManifest = Get-Content "$RepoRoot\assets\AppxManifest.xml" -Raw
$appxManifest = $appxManifest.Replace('$VERSION$', $ProductVersion)
Set-Content -Path "$ProductSourcePath\AppxManifest.xml" -Value $appxManifest -Force
# Necessary image assets need to be in source assets folder
$assets = @(
'Square150x150Logo.png'
'Square44x44Logo.png'
'Square44x44Logo.targetsize-48.png'
'Square44x44Logo.targetsize-48_altform-unplated.png'
'StoreLogo.png'
)
if (!(Test-Path "$ProductSourcePath\assets")) {
$null = New-Item -ItemType Directory -Path "$ProductSourcePath\assets"
}
$assets | ForEach-Object {
Copy-Item -Path "$RepoRoot\assets\$_" -Destination "$ProductSourcePath\assets\"
}
if ($PSCmdlet.ShouldProcess("Create .msix package?")) {
Write-Verbose "Creating priconfig.xml" -Verbose
Start-NativeExecution -VerboseOutputOnError { & $makepri createconfig /o /cf (Join-Path $ProductSourcePath "priconfig.xml") /dq en-US }
Write-Verbose "Creating resources.pri" -Verbose
Push-Location $ProductSourcePath
Start-NativeExecution -VerboseOutputOnError { & $makepri new /v /o /pr $ProductSourcePath /cf (Join-Path $ProductSourcePath "priconfig.xml") }
Pop-Location
Write-Verbose "Creating msix package" -Verbose
Start-NativeExecution -VerboseOutputOnError { & $makeappx pack /o /v /h SHA256 /d $ProductSourcePath /p (Join-Path -Path $PWD -ChildPath "$packageName.msix") }
Write-Verbose "Created $packageName.msix" -Verbose
}
}
# verify no files have been added or removed
# if so, write an error with details
function Test-FileWxs

View File

@ -19,6 +19,10 @@ COPY wix.psm1 containerFiles/wix.psm1
RUN Import-Module ./containerFiles/wix.psm1; `
Install-WixZip -zipPath \wix.Zip
# Install makeappx and makepri
ADD https://pscoretestdata.blob.core.windows.net/build-files/makeappx/makeappx.zip?sp=r&st=2019-04-05T18:02:52Z&se=2020-04-06T02:02:52Z&spr=https&sv=2018-03-28&sig=t07uC1K3uFLtINQsmorHobgPh%2B%2BBgjFnmHEJGNZT6Hk%3D&sr=b /makeappx.zip
RUN Expand-Archive /makeappx.zip
COPY PowerShellPackage.ps1 /
ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1

View File

@ -116,12 +116,19 @@ try{
$pspackageParams = @{'Type'='msi'; 'WindowsRuntime'=$Runtime}
}
if (!$ComponentRegistration.IsPresent -and !$Symbols.IsPresent -and $Runtime -notmatch "arm" -and $Runtime -ne 'fxdependent')
if (!$ComponentRegistration.IsPresent -and !$Symbols.IsPresent -and $Runtime -notmatch 'arm' -and $Runtime -ne 'fxdependent')
{
Write-Verbose "Starting powershell packaging(msi)..." -verbose
Start-PSPackage @pspackageParams @releaseTagParam
}
if (!$ComponentRegistration.IsPresent -and !$Symbols.IsPresent -and $Runtime -notin 'win7-x86','fxdependent')
{
$pspackageParams['Type']='msix'
Write-Verbose "Starting powershell packaging(msix)..." -verbose
Start-PSPackage @pspackageParams @releaseTagParam
}
if (!$ComponentRegistration.IsPresent -and $Runtime -ne 'fxdependent')
{
$pspackageParams['Type']='zip'
@ -131,7 +138,7 @@ try{
Write-Verbose "Exporting packages ..." -verbose
Get-ChildItem $location\*.msi,$location\*.zip,$location\*.wixpdb | ForEach-Object {
Get-ChildItem $location\*.msi,$location\*.zip,$location\*.wixpdb,$location\*.msix | ForEach-Object {
$file = $_.FullName
Write-Verbose "Copying $file to $destination" -verbose
Copy-Item -Path $file -Destination "$destination\" -Force

View File

@ -2,6 +2,7 @@ parameters:
architecture: x86
version: 6.2.0
msi: yes
msix: yes
steps:
- template: upload-final-results.yml
@ -34,3 +35,19 @@ steps:
storage: '$(StorageAccount)'
ContainerName: '$(AzureVersion)'
condition: and(succeeded(), eq(variables['Build.Reason'], 'Manual'))
- template: upload-final-results.yml
parameters:
artifactPath: $(Build.StagingDirectory)\signedPackages
artifactFilter: PowerShell-${{ parameters.version }}-win-${{ parameters.architecture }}.msix
condition: and(succeeded(), eq('${{ parameters.msix }}', 'yes'))
- task: AzureFileCopy@1
displayName: 'upload signed msix to Azure - ${{ parameters.architecture }}'
inputs:
SourcePath: '$(Build.StagingDirectory)\signedPackages\PowerShell-${{ parameters.version }}-win-${{ parameters.architecture }}.msix'
azureSubscription: '$(AzureFileCopySubscription)'
Destination: AzureBlob
storage: '$(StorageAccount)'
ContainerName: '$(AzureVersion)'
condition: and(succeeded(), eq('${{ parameters.msix }}', 'yes'), eq(variables['Build.Reason'], 'Manual'))

View File

@ -34,7 +34,14 @@ jobs:
continueOnError: true
- powershell: |
tools/releaseBuild/generatePackgeSigning.ps1 -AuthenticodeFiles "$(System.ArtifactsDirectory)\signed\PowerShell-$(Version)-win-x64.msi","$(System.ArtifactsDirectory)\signed\PowerShell-$(Version)-win-x86.msi" -path "$(System.ArtifactsDirectory)\package.xml"
$authenticodefiles = @(
"$(System.ArtifactsDirectory)\signed\PowerShell-$(Version)-win-x64.msi"
"$(System.ArtifactsDirectory)\signed\PowerShell-$(Version)-win-x86.msi"
"$(System.ArtifactsDirectory)\signed\PowerShell-$(Version)-win-x64.msix"
"$(System.ArtifactsDirectory)\signed\PowerShell-$(Version)-win-arm32.msix"
"$(System.ArtifactsDirectory)\signed\PowerShell-$(Version)-win-arm64.msix"
)
tools/releaseBuild/generatePackgeSigning.ps1 -AuthenticodeFiles $authenticodeFiles -path "$(System.ArtifactsDirectory)\package.xml"
displayName: 'Generate Package Signing Xml'
- powershell: |
@ -56,6 +63,7 @@ jobs:
parameters:
architecture: x86
version: $(version)
msix: no
- template: upload.yml
parameters:
@ -79,6 +87,7 @@ jobs:
architecture: fxdependent
version: $(version)
msi: no
msix: no
- task: securedevelopmentteam.vss-secure-development-tools.build-task-antimalware.AntiMalware@3
displayName: 'Run Defender Scan'

View File

@ -152,7 +152,7 @@
],
"DockerImageName": "ps-winsrvcore",
"BinaryBucket": "signed",
"ArtifactsExpected": 3,
"ArtifactsExpected": 4,
"EnableFeature": [ "ArtifactAsFolder" ]
},
{
@ -190,7 +190,7 @@
],
"DockerImageName": "ps-winsrvcore",
"BinaryBucket": "signed",
"ArtifactsExpected": 1,
"ArtifactsExpected": 2,
"EnableFeature": [ "ArtifactAsFolder" ]
},
{
@ -209,7 +209,7 @@
],
"DockerImageName": "ps-winsrvcore",
"BinaryBucket": "signed",
"ArtifactsExpected": 1,
"ArtifactsExpected": 2,
"EnableFeature": [ "ArtifactAsFolder" ]
},
{