8000 Enable building of msix package by SteveL-MSFT · Pull Request #9289 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dotnet-uninstall-debian-packages.sh
*.exe
*.msi
*.appx
*.msix

# Ignore binaries and symbols
*.pdb
Expand Down
49 changes: 49 additions & 0 deletions assets/AppxManifest.xml
Original file line number Diff line number Diff line change
@@ -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" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only 1809?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried the msix on 1803 and it didn't install understand msix, I think it only supports .appx.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can update the version information once we verify it'll work on those versions.

</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 added assets/Square150x150Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Square44x44Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Square44x44Logo.targetsize-48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/StoreLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
117 changes: 115 additions & 2 deletions tools/packaging/packaging.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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!"
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 .\to 8000 ols\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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down
17 changes: 17 additions & 0 deletions tools/releaseBuild/azureDevOps/templates/upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ parameters:
architecture: x86
version: 6.2.0
msi: yes
msix: yes

steps:
- template: upload-final-results.yml
Expand Down Expand Up @@ -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.StagingDir 8000 ectory)\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'))
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -56,6 +63,7 @@ jobs:
parameters:
architecture: x86
version: $(version)
msix: no

- template: upload.yml
parameters:
Expand All @@ -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'
Expand Down
6 changes: 3 additions & 3 deletions tools/releaseBuild/build.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
],
"DockerImageName": "ps-winsrvcore",
"BinaryBucket": "signed",
"ArtifactsExpected": 3,
"ArtifactsExpected": 4,
"EnableFeature": [ "ArtifactAsFolder" ]
},
{
Expand Down Expand Up @@ -190,7 +190,7 @@
],
"DockerImageName": "ps-winsrvcore",
"BinaryBucket": "signed",
"ArtifactsExpected": 1,
"ArtifactsExpected": 2,
"EnableFeature": [ "ArtifactAsFolder" ]
},
{
Expand All @@ -209,7 +209,7 @@
],
"DockerImageName": "ps-winsrvcore",
"BinaryBucket": "signed",
"ArtifactsExpected": 1,
"ArtifactsExpected": 2,
"EnableFeature": [ "ArtifactAsFolder" ]
},
{
Expand Down
0