X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
634ddd5
refactor exe wrapper generation into separate function
TravisEz13 Mar 24, 2021
53d3d0f
generate exe wrapper after msi is signed
TravisEz13 Mar 24, 2021
93e4684
don't sign msi again
TravisEz13 Mar 24, 2021
cbe5f00
don't upload msi agin
TravisEz13 Mar 24, 2021
3351bba
fix version
TravisEz13 Mar 25, 2021
3d82cbf
fix working directory for exe build
TravisEz13 Mar 25, 2021
9d2d984
add logging for getting windows names
TravisEz13 Mar 25, 2021
a804c47
add signing task display name
TravisEz13 Mar 25, 2021
bbde77f
sign engine exe in exe wrapper
TravisEz13 Mar 25, 2021
a3bb634
fix typo
TravisEz13 Mar 25, 2021
4ff5f6e
fix typo
TravisEz13 Mar 26, 2021
1b10180
go back to master for compliance repo
TravisEz13 Mar 26, 2021
4b8bc55
test engine mounted in exe wrapper
TravisEz13 Mar 26, 2021
94ac51f
exclude packaging from future windows CI builds
TravisEz13 Mar 31, 2021
f559332
fix package CI
TravisEz13 Apr 1, 2021
89cb3db
change function names
TravisEz13 Apr 7, 2021
df63723
Update tools/releaseBuild/azureDevOps/templates/windows-packaging.yml
TravisEz13 Apr 7, 2021
18b7f75
Update tools/releaseBuild/azureDevOps/templates/windows-packaging.yml
TravisEz13 Apr 7, 2021
6f884c5
Update tools/releaseBuild/azureDevOps/templates/windows-packaging.yml
TravisEz13 Apr 7, 2021
953bb7d
Update tools/releaseBuild/azureDevOps/templates/windows-packaging.yml
TravisEz13 Apr 7, 2021
24da08b
Apply suggestions from code review
TravisEz13 Apr 8, 2021
a22dbdd
add comments per review comments
TravisEz13 Apr 7, 2021
042ae12
fix replace
TravisEz13 Apr 8, 2021
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
10 changes: 5 additions & 5 deletions .vsts-ci/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ pr:
include:
- '*'
exclude:
- test/common/markdown/*
- tools/releaseBuild/*
- tools/releaseBuild/azureDevOps/templates/*
- .vsts-ci/misc-analysis.yml
- .github/ISSUE_TEMPLATE/*
- .dependabot/config.yml
- .github/ISSUE_TEMPLATE/*
- .vsts-ci/misc-analysis.yml
- .vsts-ci/windows.yml
- .vsts-ci/windows/*
- test/common/markdown/*
- tools/releaseBuild/*
- tools/releaseBuild/azureDevOps/templates/*

variables:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
Expand Down
11 changes: 6 additions & 5 deletions .vsts-ci/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ pr:
include:
- '*'
exclude:
- test/common/markdown/*
- .vsts-ci/misc-analysis.yml
- .github/ISSUE_TEMPLATE/*
- .dependabot/config.yml
- tools/releaseBuild/*
- tools/releaseBuild/azureDevOps/templates/*
- .github/ISSUE_TEMPLATE/*
- .vsts-ci/misc-analysis.yml
- /.vsts-ci/windows.yml
- /.vsts-ci/windows/*
- test/common/markdown/*
- tools/packaging/*
- tools/releaseBuild/*
- tools/releaseBuild/azureDevOps/templates/*

variables:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
Expand Down
7 changes: 4 additions & 3 deletions .vsts-ci/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ pr:
include:
- '*'
exclude:
- .vsts-ci/misc-analysis.yml
- .github/ISSUE_TEMPLATE/*
- .dependabot/config.yml
- .github/ISSUE_TEMPLATE/*
- .vsts-ci/misc-analysis.yml
- test/common/markdown/*
- tools/packaging/*
- tools/releaseBuild/*
- tools/releaseBuild/azureDevOps/templates/*
- test/common/markdown/*

variables:
GIT_CONFIG_PARAMETERS: "'core.autocrlf=false'"
Expand Down
6 changes: 5 additions & 1 deletion tools/ci.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,11 @@ function Invoke-CIFinish

# the packaging tests find the MSI package using env:PSMsiX64Path
$env:PSMsiX64Path = $artifacts | Where-Object { $_.EndsWith(".msi")}
$env:PSExePath = $artifacts | Where-Object { $_.EndsWith(".exe") }
$architechture = $Runtime.Split('-')[1]
$exePath = New-ExePackage -ProductVersion ($preReleaseVersion -replace '^v') -ProductTargetArchitecture $architechture -MsiLocationPath $env:PSMsiX64Path
Write-Verbose "exe Path: $exePath" -Verbose
$artifacts.Add($exePath)
$env:PSExePath = $exePath
$env:PSMsiChannel = $Channel
$env:PSMsiRuntime = $Runtime

Expand Down
34 changes: 24 additions & 10 deletions tools/packaging/packaging.psd1
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
@{
GUID="41857994-4283-4757-a932-0b0edb104913"
Author="PowerShell"
CompanyName="Microsoft Corporation"
Copyright="Copyright (c) Microsoft Corporation."
ModuleVersion="1.0.0"
PowerShellVersion="5.0"
CmdletsToExport=@()
FunctionsToExport=@('Start-PSPackage','New-PSSignedBuildZip', 'New-PSBuildZip', 'New-MSIPatch', 'Expand-PSSignedBuild', 'Publish-NugetToMyGet', 'New-DotnetSdkContainerFxdPackage', 'New-GlobalToolNupkg', 'New-ILNugetPackage', 'Update-PSSignedBuildFolder')
RootModule="packaging.psm1"
RequiredModules = @("build")
GUID = "41857994-4283-4757-a932-0b0edb104913"
Author = "PowerShell"
CompanyName = "Microsoft Corporation"
Copyright = "Copyright (c) Microsoft Corporation."
ModuleVersion = "1.0.0"
PowerShellVersion = "5.0"
CmdletsToExport = @()
FunctionsToExport = @(
'Expand-ExePackageEngine'
'Expand-PSSignedBuild'
'Compress-ExePackageEngine'
'New-DotnetSdkContainerFxdPackage'
'New-ExePackage'
'New-GlobalToolNupkg'
'New-ILNugetPackage'
'New-MSIPatch'
'New-PSBuildZip'
'New-PSSignedBuildZip'
'Publish-NugetToMyGet'
'Start-PSPackage'
'Update-PSSignedBuildFolder'
)
RootModule = "packaging.psm1"
RequiredModules = @("build")
}
186 changes: 159 additions & 27 deletions tools/packaging/packaging.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2832,14 +2832,16 @@ function Get-WixPath
$wixPyroExePath = Join-Path $wixToolsetBinPath "pyro.exe"
$wixCandleExePath = Join-Path $wixToolsetBinPath "Candle.exe"
$wixLightExePath = Join-Path $wixToolsetBinPath "Light.exe"
$wixInsigniaExePath = Join-Path $wixToolsetBinPath "Insignia.exe"

return [PSCustomObject] @{
WixHeatExePath = $wixHeatExePath
WixMeltExePath = $wixMeltExePath
WixTorchExePath = $wixTorchExePath
WixPyroExePath = $wixPyroExePath
WixCandleExePath = $wixCandleExePath
WixLightExePath = $wixLightExePath
WixHeatExePath = $wixHeatExePath
WixMeltExePath = $wixMeltExePath
WixTorchExePath = $wixTorchExePath
WixPyroExePath = $wixPyroExePath
WixCandleExePath = $wixCandleExePath
WixLightExePath = $wixLightExePath
WixInsigniaExePath = $wixInsigniaExePath
}

}
Expand Down Expand Up @@ -3046,8 +3048,15 @@ function New-MSIPackage

$wixPaths = Get-WixPath

$ProductSemanticVersion = Get-PackageSemanticVersion -Version $ProductVersion
$ProductVersion = Get-PackageVersionAsMajorMinorBuildRevision -Version $ProductVersion
$windowsNames = Get-WindowsNames -ProductName $ProductName -ProductNameSuffix $ProductNameSuffix -ProductVersion $ProductVersion
$productSemanticVersionWithName = $windowsNames.ProductSemanticVersionWithName
$ProductSemanticVersion = $windowsNames.ProductSemanticVersion
$packageName = $windowsNames.PackageName
$ProductVersion = $windowsNames.ProductVersion
Write-Verbose "Create MSI for Product $productSemanticVersionWithName" -Verbose
Write-Verbose "ProductSemanticVersion = $productSemanticVersion" -Verbose
Write-Verbose "packageName = $packageName" -Verbose
Write-Verbose "ProductVersion = $ProductVersion" -Verbose

$simpleProductVersion = [string]([Version]$ProductVersion).Major
$isPreview = Test-IsPreview -Version $ProductSemanticVersion
Expand All @@ -3068,10 +3077,7 @@ function New-MSIPackage
Write-Verbose "Place dependencies such as icons to $assetsInSourcePath"
Copy-Item "$AssetsPath\*.ico" $assetsInSourcePath -Force

$productVersionWithName = $ProductName + '_' + $ProductVersion
$productSemanticVersionWithName = $ProductName + '-' + $ProductSemanticVersion

Write-Verbose "Create MSI for Product $productSemanticVersionWithName"

$fileArchitecture = 'amd64'
$ProductProgFilesDir = "ProgramFiles64Folder"
Expand All @@ -3086,11 +3092,6 @@ function New-MSIPackage
# cleanup any garbage on the system
Remove-Item -ErrorAction SilentlyContinue $wixFragmentPath -Force

$packageName = $productSemanticVersionWithName
if ($ProductNameSuffix) {
$packageName += "-$ProductNameSuffix"
}

$msiLocationPath = Join-Path $CurrentLocation "$packageName.msi"
$msiPdbLocationPath = Join-Path $CurrentLocation "$packageName.wixpdb"

Expand Down Expand Up @@ -3150,27 +3151,158 @@ function New-MSIPackage
$errorMessage = "Failed to create $msiLocationPath"
throw $errorMessage
}
}

function Get-WindowsNames {
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
)

Write-Verbose -Message "Getting Windows Names for ProductName: $ProductName; ProductNameSuffix: $ProductNameSuffix; ProductVersion: $ProductVersion" -Verbose

$ProductSemanticVersion = Get-PackageSemanticVersion -Version $ProductVersion
$ProductVersion = Get-PackageVersionAsMajorMinorBuildRevision -Version $ProductVersion

$productVersionWithName = $ProductName + '_' + $ProductVersion
$productSemanticVersionWithName = $ProductName + '-' + $ProductSemanticVersion

$packageName = $productSemanticVersionWithName
if ($ProductNameSuffix) {
$packageName += "-$ProductNameSuffix"
}

return [PSCustomObject]@{
PackageName = $packageName
ProductVersionWithName = $productVersionWithName
ProductSemanticVersion = $ProductSemanticVersion
ProductSemanticVersionWithName = $productSemanticVersionWithName
ProductVersion = $ProductVersion
}
}

function New-ExePackage {
param(
# Name of the Product
[ValidateNotNullOrEmpty()]
[string] $ProductName = 'PowerShell',

# Version of the Product
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]

[string] $ProductVersion,

# File describing the MSI Package creation semantics
[ValidateNotNullOrEmpty()]
[ValidateScript({Test-Path $_})]
[string] $BundleWxsPath = "$RepoRoot\assets\wix\bundle.wxs",

# Architecture to use when creating the MSI
[Parameter(Mandatory = $true)]
[ValidateSet("x86", "x64")]
[ValidateNotNullOrEmpty()]
[string] $ProductTargetArchitecture,

# Location of the signed MSI
[Parameter(Mandatory = $true)]
[string]
$MsiLocationPath,

[string] $CurrentLocation = (Get-Location)
)

$productNameSuffix = "win-$ProductTargetArchitecture"

$windowsNames = Get-WindowsNames -ProductName $ProductName -ProductNameSuffix $productNameSuffix -ProductVersion $ProductVersion
$productSemanticVersionWithName = $windowsNames.ProductSemanticVersionWithName
$packageName = $windowsNames.PackageName
$isPreview = Test-IsPreview -Version $windowsNames.ProductSemanticVersion

Write-Verbose "Create EXE for Product $productSemanticVersionWithName" -verbose
Write-Verbose "packageName = $packageName" -Verbose

$exeLocationPath = Join-Path $CurrentLocation "$packageName.exe"
$exePdbLocationPath = Join-Path $CurrentLocation "$packageName.exe.wixpdb"
$windowsVersion = Get-WindowsVersion -packageName $packageName

Start-MsiBuild -WxsFile $BundleWxsPath -ProductTargetArchitecture $ProductTargetArchitecture -Argument @{
IsPreview = $isPreview
TargetPath = $msiLocationPath
TargetPath = $MsiLocationPath
WindowsVersion = $windowsVersion
} -MsiLocationPath $exeLocationPath -MsiPdbLocationPath $exePdbLocationPath

if (Test-Path $exeLocationPath)
{
Write-Verbose "You can find the MSI @ $exeLocationPath" -Verbose
$exeLocationPath
}
else
{
$errorMessage = "Failed to create $exeLocationPath"
throw $errorMessage
}
return $exeLocationPath
}

<#
Allows you to extract the engine of exe package, mainly for signing
Any existing signature will be removed.
#>
function Expand-ExePackageEngine {
param(
# Location of the unsigned EXE
[Parameter(Mandatory = $true)]
[string]
$ExePath,

# Location to put the expanded engine.
[Parameter(Mandatory = $true)]
[string]
$EnginePath
)

<#
2. detach the engine from TestInstaller.exe:
insignia -ib TestInstaller.exe -o engine.exe
#>

$wixPaths = Get-WixPath

$resolvedExePath = (Resolve-Path -Path $ExePath).ProviderPath
$resolvedEnginePath = [System.IO.Path]::GetFullPath($EnginePath)

Start-NativeExecution -VerboseOutputOnError { & $wixPaths.wixInsigniaExePath -ib $resolvedExePath -o $resolvedEnginePath}
}

<#
Allows you to replace the engine (installer) in the exe package.
Used to replace the engine with a signed version
#>
function Compress-ExePackageEngine {
param(
# Location of the unsigned EXE
[Parameter(Mandatory = $true)]
[string]
$ExePath,

# Location of the signed engine
[Parameter(Mandatory = $true)]
[string]
$EnginePath
)


<#
4. re-attach the signed engine.exe to the bundle:
insignia -ab engine.exe TestInstaller.exe -o TestInstaller.exe
#>

$wixPaths = Get-WixPath

$resolvedEnginePath = (Resolve-Path -Path $EnginePath).ProviderPath
$resolvedExePath = (Resolve-Path -Path $ExePath).ProviderPath

Start-NativeExecution -VerboseOutputOnError { & $wixPaths.wixInsigniaExePath -ab $resolvedEnginePath $resolvedExePath -o $resolvedExePath}
}

function New-MsiArgsArray {
Expand Down
1 change: 1 addition & 0 deletions tools/releaseBuild/azureDevOps/templates/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ jobs:
**\*.rpm
useMinimatch: true
shouldSign: $(SHOULD_SIGN)
displayName: Sign RPM

# requires windows
- task: AzureFileCopy@4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ jobs:
**\*.zip
useMinimatch: true
shouldSign: $(SHOULD_SIGN)
displayName: Sign macOS Binaries

- pwsh: |
$destination = "$(System.ArtifactsDirectory)\azureMacOs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
**\*.zip
useMinimatch: true
shouldSign: $(SHOULD_SIGN)
displayName: Sign pkg

- template: upload-final-results.yml
parameters:
Expand Down
1 change: 1 addition & 0 deletions tools/releaseBuild/azureDevOps/templates/nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ jobs:
**\*.nupkg
useMinimatch: true
shouldSign: $(SHOULD_SIGN)
displayName: Sign NuPkg

- pwsh: |
if (-not (Test-Path '$(System.ArtifactsDirectory)\signed\')) { $null = New-Item -ItemType Directory -Path '$(System.ArtifactsDirectory)\signed\' }
Expand Down
17 changes: 0 additions & 17 deletions tools/releaseBuild/azureDevOps/templates/upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,6 @@ parameters:
pdb: no

steps:
- template: upload-final-results.yml
parameters:
artifactPath: $(Build.StagingDirectory)\signedPackages
artifactFilter: PowerShell-${{ parameters.version }}-win-${{ parameters.architecture }}.msi
condition: and(succeeded(), eq('${{ parameters.msi }}', 'yes'))

- task: AzureFileCopy@4
displayName: 'upload signed msi to Azure - ${{ parameters.architecture }}'
inputs:
SourcePath: '$(Build.StagingDirectory)\signedPackages\PowerShell-${{ parameters.version }}-win-${{ parameters.architecture }}.msi'
azureSubscription: '$(AzureFileCopySubscription)'
Destination: AzureBlob
storage: '$(StorageAccount)'
ContainerName: '$(AzureVersion)'
resourceGroup: '$(StorageResourceGroup)'
condition: and(succeeded(), eq('${{ parameters.msi }}', 'yes'))

- template: upload-final-results.yml
parameters:
artifactPath: $(System.ArtifactsDirectory)\signed
Expand Down
Loading
X Tutup