diff --git a/.gitignore b/.gitignore index fa3322aea1..214134621d 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ dotnet-install.ps1 # Ignore executables *.exe *.msi +*.appx # Ignore packages *.deb diff --git a/Assets/Powershell_16.png b/Assets/Powershell_16.png new file mode 100644 index 0000000000..acc6c493b1 Binary files /dev/null and b/Assets/Powershell_16.png differ diff --git a/Assets/Powershell_20.png b/Assets/Powershell_20.png new file mode 100644 index 0000000000..df170bf6e8 Binary files /dev/null and b/Assets/Powershell_20.png differ diff --git a/Assets/Powershell_24.png b/Assets/Powershell_24.png new file mode 100644 index 0000000000..3189510697 Binary files /dev/null and b/Assets/Powershell_24.png differ diff --git a/Assets/Powershell_256.png b/Assets/Powershell_256.png new file mode 100644 index 0000000000..8767330b82 Binary files /dev/null and b/Assets/Powershell_256.png differ diff --git a/Assets/Powershell_32.png b/Assets/Powershell_32.png new file mode 100644 index 0000000000..e801ee7e8d Binary files /dev/null and b/Assets/Powershell_32.png differ diff --git a/Assets/Powershell_40.png b/Assets/Powershell_40.png new file mode 100644 index 0000000000..f34dd54a48 Binary files /dev/null and b/Assets/Powershell_40.png differ diff --git a/Assets/Powershell_48.png b/Assets/Powershell_48.png new file mode 100644 index 0000000000..716c2aa5b6 Binary files /dev/null and b/Assets/Powershell_48.png differ diff --git a/Assets/Powershell_64.png b/Assets/Powershell_64.png new file mode 100644 index 0000000000..2a656ffc3c Binary files /dev/null and b/Assets/Powershell_64.png differ diff --git a/appveyor.yml b/appveyor.yml index 8bbc05f39b..f4e3237ef7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -66,7 +66,8 @@ on_finish: $ErrorActionPreference = 'Stop' try { # Build package - $package = Start-PSPackage + $packages = Start-PSPackage + # Creating project artifact $name = git describe $zipFilePath = Join-Path $pwd "$name.zip" @@ -75,10 +76,14 @@ on_finish: [System.IO.Compression.ZipFile]::CreateFromDirectory($env:CoreOutput, $zipFilePath) [System.IO.Compression.ZipFile]::CreateFromDirectory($env:FullOutput, $zipFileFullPath) - $artifacts = @( - $package, - $zipFilePath, - $zipFileFullPath + $artifacts = New-Object System.Collections.ArrayList + foreach ($package in $packages) { + $artifacts.Add($package) + } + + $artifacts.Add($zipFilePath) + $artifacts.Add($zipFileFullPath) + ) Publish-NuGetFeed -OutputPath .\nuget-artifacts -VersionSuffix "b$($env:APPVEYOR_BUILD_NUMBER)" diff --git a/build.psm1 b/build.psm1 index bb1fed04ac..ea765497ea 100644 --- a/build.psm1 +++ b/build.psm1 @@ -441,7 +441,12 @@ Built upon .NET Core, it is also a C# REPL. Write-Verbose "Packaging $Source" if ($IsWindows) { - return Create-MSIPackage -ProductSourcePath $Source -ProductVersion $Version -Verbose + $msiPackagePath = Create-MSIPackage -ProductSourcePath $Source -ProductVersion $Version -Verbose + $appxPackagePath = New-AppxPackage -PackageVersion $Version -SourcePath $Source -AssetsPath "$PSScriptRoot\Assets" -Verbose + + $packages = @($msiPackagePath, $appxPackagePath) + + return $packages } if (-not (Get-Command "fpm" -ErrorAction SilentlyContinue)) { @@ -1021,3 +1026,109 @@ function Create-MSIPackage return $msiLocationPath } +# Function to create an Appx package compatible with Windows 8.1 and above +function New-AppxPackage +{ + [CmdletBinding()] + param ( + + # Name of the Package + [ValidateNotNullOrEmpty()] + [string] $PackageName = 'OpenPowerShell', + + # Version of the Package + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] $PackageVersion, + + # Source Path to the Binplaced Files + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] $SourcePath, + + # Path to Assets folder containing Appx specific artifacts + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] $AssetsPath + ) + + Write-Verbose "Extract the version in the form of a.b.c.d" + $PackageVersion = ([regex]::matches($PackageVersion, "\d+(\.\d+)+"))[0].value + Write-Verbose "Package Version is $PackageVersion" + + $win10sdkBinPath = "${env:ProgramFiles(x86)}\Windows Kits\10\bin\x64" + + Write-Verbose "Ensure Win10 SDK is present on the machine @ $win10sdkBinPath" + if (-not (Test-Path $win10sdkBinPath)) + { + throw "Install Win10 SDK prior to running this script - https://go.microsoft.com/fwlink/p/?LinkID=698771" + } + + Write-Verbose "Ensure Source Path is valid - $SourcePath" + if (-not (Test-Path $SourcePath)) + { + throw "Invalid SourcePath - $SourcePath" + } + + Write-Verbose "Ensure Assets Path is valid - $AssetsPath" + if (-not (Test-Path $AssetsPath)) + { + throw "Invalid AssetsPath - $AssetsPath" + } + + Write-Verbose "Initialize MakeAppx executable path" + $makeappxExePath = Join-Path $win10sdkBinPath "MakeAppx.exe" + + $appxManifest = @" + + + + OpenPowerShell + Microsoft Corporation + #LOGO# + + + + + + + + + + + + + + + + + + +"@ + + $appxManifest = $appxManifest.Replace('#VERSION#', $PackageVersion) + $appxManifest = $appxManifest.Replace('#LOGO#', 'Assets\Powershell_256.png') + $appxManifest = $appxManifest.Replace('#SQUARE150x150LOGO#', 'Assets\Powershell_256.png') + $appxManifest = $appxManifest.Replace('#SQUARE44x44LOGO#', 'Assets\Powershell_48.png') + + Write-Verbose "Place Appx Manifest in $SourcePath" + $appxManifest | Out-File "$SourcePath\AppxManifest.xml" -Force + + $assetsInSourcePath = "$SourcePath" + '\Assets' + New-Item $assetsInSourcePath -type directory -Force | Out-Null + + $assetsInSourcePath = Join-Path $SourcePath 'Assets' + + Write-Verbose "Place AppxManifest dependencies such as images to $assetsInSourcePath" + Copy-Item "$AssetsPath\*.png" $assetsInSourcePath -Force + + $appxPackagePath = "$pwd\$PackageName_$PackageVersion.appx" + Write-Verbose "Calling MakeAppx from $makeappxExePath to create the package @ $appxPackagePath" + & $makeappxExePath pack /o /v /d $SourcePath /p $appxPackagePath | Write-Verbose + + Write-Verbose "Clean-up Appx artifacts and Assets from $SourcePath" + Remove-Item $assetsInSourcePath -Recurse -Force -ErrorAction SilentlyContinue + Remove-Item "$SourcePath\AppxManifest.xml" -Force -ErrorAction SilentlyContinue + + return $appxPackagePath +}