2020-02-14 17:44:43 +01:00
|
|
|
parameters:
|
2020-11-05 22:28:40 +01:00
|
|
|
- name: BuildConfiguration
|
|
|
|
default: release
|
|
|
|
- name: BuildPlatform
|
|
|
|
default: any cpu
|
|
|
|
- name: Architecture
|
|
|
|
default: x64
|
|
|
|
- name: parentJob
|
|
|
|
default: ''
|
2020-02-14 17:44:43 +01:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
- job: sign_windows_${{ parameters.Architecture }}
|
|
|
|
displayName: Package Windows - ${{ parameters.Architecture }}
|
|
|
|
condition: succeeded()
|
|
|
|
dependsOn: ${{ parameters.parentJob }}
|
|
|
|
pool:
|
2020-11-11 21:09:55 +01:00
|
|
|
vmImage: windows-latest
|
2020-02-14 17:44:43 +01:00
|
|
|
variables:
|
2020-11-05 22:28:40 +01:00
|
|
|
- name: BuildConfiguration
|
|
|
|
value: ${{ parameters.BuildConfiguration }}
|
|
|
|
- name: BuildPlatform
|
|
|
|
value: ${{ parameters.BuildPlatform }}
|
|
|
|
- name: Architecture
|
|
|
|
value: ${{ parameters.Architecture }}
|
|
|
|
- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE
|
|
|
|
value: 1
|
|
|
|
- group: ESRP
|
2020-02-14 17:44:43 +01:00
|
|
|
|
|
|
|
steps:
|
|
|
|
|
|
|
|
- checkout: self
|
|
|
|
clean: true
|
|
|
|
|
2020-11-05 22:28:40 +01:00
|
|
|
- checkout: ComplianceRepo
|
|
|
|
clean: true
|
|
|
|
|
2020-02-14 17:44:43 +01:00
|
|
|
- template: shouldSign.yml
|
|
|
|
- template: SetVersionVariables.yml
|
|
|
|
parameters:
|
|
|
|
ReleaseTagVar: $(ReleaseTagVar)
|
|
|
|
|
|
|
|
- powershell: |
|
|
|
|
$pkgFilter = if ( '$(Architecture)' -eq 'arm' ) {
|
|
|
|
"arm32"
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
'$(Architecture)'
|
|
|
|
}
|
|
|
|
|
|
|
|
$vstsCommandString = "vso[task.setvariable variable=PkgFilter]$pkgFilter"
|
|
|
|
Write-Host ("sending " + $vstsCommandString)
|
|
|
|
Write-Host "##$vstsCommandString"
|
|
|
|
displayName: Set packageName variable
|
|
|
|
|
|
|
|
- task: DownloadBuildArtifacts@0
|
|
|
|
inputs:
|
|
|
|
artifactName: 'results'
|
|
|
|
itemPattern: '**/*$(PkgFilter).zip'
|
|
|
|
downloadPath: '$(System.ArtifactsDirectory)\Symbols'
|
|
|
|
|
2020-11-05 22:28:40 +01:00
|
|
|
- template: cloneToOfficialPath.yml
|
2020-02-14 17:44:43 +01:00
|
|
|
|
|
|
|
- powershell: |
|
|
|
|
# cleanup previous install
|
|
|
|
if((Test-Path "${env:ProgramFiles(x86)}\WiX Toolset xcopy")) {
|
|
|
|
Remove-Item "${env:ProgramFiles(x86)}\WiX Toolset xcopy" -Recurse -Force
|
|
|
|
}
|
|
|
|
|
|
|
|
$toolsDir = New-Item -ItemType Directory -Path '$(Build.ArtifactStagingDirectory)\tools'
|
|
|
|
$wixUri = 'https://github.com/wixtoolset/wix3/releases/download/wix311rtm/wix311-binaries.zip'
|
|
|
|
Invoke-RestMethod -Uri $wixUri -OutFile '$(Build.ArtifactStagingDirectory)\tools\wix.zip'
|
|
|
|
|
|
|
|
Import-Module '$(PowerShellRoot)/tools/releaseBuild/Images/microsoft_powershell_windowsservercore/wix.psm1'
|
|
|
|
Install-WixZip -zipPath '$(Build.ArtifactStagingDirectory)\tools\wix.zip'
|
|
|
|
|
|
|
|
$msixUrl = '$(makeappUrl)'
|
|
|
|
Invoke-RestMethod -Uri $msixUrl -OutFile '\makeappx.zip'
|
|
|
|
Expand-Archive '\makeappx.zip' -destination '\' -Force
|
|
|
|
|
|
|
|
displayName: Install packaging tools
|
|
|
|
|
|
|
|
- powershell: |
|
|
|
|
$zipPath = Get-Item '$(System.ArtifactsDirectory)\Symbols\results\*$(PkgFilter).zip'
|
|
|
|
Write-Verbose -Verbose "Zip Path: $zipPath"
|
|
|
|
|
|
|
|
$expandedFolder = $zipPath.BaseName
|
|
|
|
Write-Host "sending.. vso[task.setvariable variable=SymbolsFolder]$expandedFolder"
|
|
|
|
Write-Host "##vso[task.setvariable variable=SymbolsFolder]$expandedFolder"
|
|
|
|
|
|
|
|
Expand-Archive -Path $zipPath -Destination "$(System.ArtifactsDirectory)\$expandedFolder" -Force
|
|
|
|
displayName: Expand symbols zip
|
|
|
|
|
2020-11-05 22:28:40 +01:00
|
|
|
- pwsh: |
|
|
|
|
$fullSymbolsFolder = "$(System.ArtifactsDirectory)\$($env:SYMBOLSFOLDER)"
|
|
|
|
|
|
|
|
$filesToSignDirectory = "$(System.ArtifactsDirectory)\toBeSigned"
|
|
|
|
$null = New-Item -ItemType Directory -Path $filesToSignDirectory -Force
|
|
|
|
|
|
|
|
$signedFilesDirectory = "$(System.ArtifactsDirectory)\signed"
|
|
|
|
$null = New-Item -ItemType Directory -Path $signedFilesDirectory -Force
|
|
|
|
|
|
|
|
$itemsToCopyWithRecurse = @(
|
2020-11-11 21:09:55 +01:00
|
|
|
"$($fullSymbolsFolder)\*.ps1"
|
|
|
|
"$($fullSymbolsFolder)\Microsoft.PowerShell*.dll"
|
2020-11-05 22:28:40 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
$itemsToCopy = @{
|
|
|
|
"$($fullSymbolsFolder)\*.ps1" = ""
|
|
|
|
"$($fullSymbolsFolder)\Microsoft.Management.Infrastructure.CimCmdlets.dll" = ""
|
|
|
|
"$($fullSymbolsFolder)\Microsoft.WSMan.*.dll" = ""
|
|
|
|
"$($fullSymbolsFolder)\Modules\CimCmdlets\CimCmdlets.psd1" = "Modules\CimCmdlets"
|
|
|
|
"$($fullSymbolsFolder)\Modules\Microsoft.PowerShell.Diagnostics\Diagnostics.format.ps1xml" = "Modules\Microsoft.PowerShell.Diagnostics"
|
|
|
|
"$($fullSymbolsFolder)\Modules\Microsoft.PowerShell.Diagnostics\Event.format.ps1xml" = "Modules\Microsoft.PowerShell.Diagnostics"
|
|
|
|
"$($fullSymbolsFolder)\Modules\Microsoft.PowerShell.Diagnostics\GetEvent.types.ps1xml" = "Modules\Microsoft.PowerShell.Diagnostics"
|
2020-11-11 21:09:55 +01:00
|
|
|
"$($fullSymbolsFolder)\Modules\Microsoft.PowerShell.Diagnostics\Microsoft.PowerShell.Diagnostics.psd1" = "Modules\Microsoft.PowerShell.Diagnostics"
|
|
|
|
"$($fullSymbolsFolder)\Modules\Microsoft.PowerShell.Host\Microsoft.PowerShell.Host.psd1" = "Modules\Microsoft.PowerShell.Host"
|
|
|
|
"$($fullSymbolsFolder)\Modules\Microsoft.PowerShell.Management\Microsoft.PowerShell.Management.psd1" = "Modules\Microsoft.PowerShell.Management"
|
|
|
|
"$($fullSymbolsFolder)\Modules\Microsoft.PowerShell.Security\Microsoft.PowerShell.Security.psd1" = "Modules\Microsoft.PowerShell.Security"
|
|
|
|
"$($fullSymbolsFolder)\Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psd1" = "Modules\Microsoft.PowerShell.Utility"
|
2020-11-05 22:28:40 +01:00
|
|
|
"$($fullSymbolsFolder)\Modules\Microsoft.WSMan.Management\Microsoft.WSMan.Management.psd1" = "Modules\Microsoft.WSMan.Management"
|
|
|
|
"$($fullSymbolsFolder)\Modules\Microsoft.WSMan.Management\WSMan.format.ps1xml" = "Modules\Microsoft.WSMan.Management"
|
|
|
|
"$($fullSymbolsFolder)\Modules\PSDiagnostics\PSDiagnostics.ps?1" = "Modules\PSDiagnostics"
|
|
|
|
"$($fullSymbolsFolder)\pwsh.dll" = ""
|
|
|
|
"$($fullSymbolsFolder)\System.Management.Automation.dll" = ""
|
|
|
|
}
|
2020-02-14 17:44:43 +01:00
|
|
|
|
2020-12-10 22:07:53 +01:00
|
|
|
$itemsToExclude = @(
|
2020-12-09 21:29:45 +01:00
|
|
|
# This package is retrieved from https://www.github.com/powershell/MarkdownRender
|
|
|
|
"$($fullSymbolsFolder)\Microsoft.PowerShell.MarkdownRender.dll"
|
2020-12-10 22:07:53 +01:00
|
|
|
)
|
2020-12-09 21:29:45 +01:00
|
|
|
|
2020-11-05 22:28:40 +01:00
|
|
|
if ("$env:Architecture" -notlike 'fxdependent*')
|
|
|
|
{
|
|
|
|
$itemsToCopy += @{"$($fullSymbolsFolder)\pwsh.exe" = ""}
|
|
|
|
}
|
2020-02-14 17:44:43 +01:00
|
|
|
|
2020-11-05 22:28:40 +01:00
|
|
|
Write-Verbose -verbose "recusively copying $($itemsToCopyWithRecurse | out-string) to $filesToSignDirectory"
|
2020-12-09 21:29:45 +01:00
|
|
|
Copy-Item -Path $itemsToCopyWithRecurse -Destination $filesToSignDirectory -Recurse -verbose -exclude $itemsToExclude
|
2020-02-14 17:44:43 +01:00
|
|
|
|
2020-11-05 22:28:40 +01:00
|
|
|
foreach($pattern in $itemsToCopy.Keys) {
|
|
|
|
$destinationFolder = Join-Path $filesToSignDirectory -ChildPath $itemsToCopy.$pattern
|
|
|
|
$null = New-Item -ItemType Directory -Path $destinationFolder -Force
|
|
|
|
Write-Verbose -verbose "copying $pattern to $destinationFolder"
|
|
|
|
Copy-Item -Path $pattern -Destination $destinationFolder -Recurse -verbose
|
|
|
|
}
|
|
|
|
displayName: 'Prepare files to be signed'
|
|
|
|
|
|
|
|
- template: EsrpSign.yml@ComplianceRepo
|
|
|
|
parameters:
|
|
|
|
buildOutputPath: $(System.ArtifactsDirectory)\toBeSigned
|
|
|
|
signOutputPath: $(System.ArtifactsDirectory)\signed
|
|
|
|
certificateId: "CP-230012"
|
|
|
|
pattern: |
|
|
|
|
**\*.dll
|
|
|
|
**\*.psd1
|
|
|
|
**\*.psm1
|
|
|
|
**\*.ps1xml
|
|
|
|
**\*.ps1
|
2020-11-11 21:09:55 +01:00
|
|
|
**\*.exe
|
2020-11-05 22:28:40 +01:00
|
|
|
useMinimatch: true
|
2020-12-09 23:51:43 +01:00
|
|
|
shouldSign: $(SHOULD_SIGN)
|
2020-11-05 22:28:40 +01:00
|
|
|
|
|
|
|
- pwsh: |
|
2020-02-14 17:44:43 +01:00
|
|
|
Import-Module $(PowerShellRoot)/build.psm1 -Force
|
|
|
|
Import-Module $(PowerShellRoot)/tools/packaging -Force
|
|
|
|
$signedFilesPath = '$(System.ArtifactsDirectory)\signed\'
|
2020-05-05 21:35:03 +02:00
|
|
|
$BuildPath = '$(System.ArtifactsDirectory)\$(SymbolsFolder)'
|
|
|
|
|
|
|
|
Update-PSSignedBuildFolder -BuildPath $BuildPath -SignedFilesPath $SignedFilesPath
|
|
|
|
$dlls = Get-ChildItem $BuildPath\*.dll -Recurse
|
|
|
|
$signatures = $dlls | Get-AuthenticodeSignature
|
|
|
|
$missingSignatures = $signatures | Where-Object { $_.status -eq 'notsigned'}| select-object -ExpandProperty Path
|
|
|
|
|
2020-11-11 21:09:55 +01:00
|
|
|
Write-Verbose -verbose "to be signed:`r`n $($missingSignatures | Out-String)"
|
|
|
|
|
|
|
|
$filesToSignDirectory = "$(System.ArtifactsDirectory)\thirdPartyToBeSigned"
|
|
|
|
$null = New-Item -ItemType Directory -Path $filesToSignDirectory -Force
|
|
|
|
|
|
|
|
$signedFilesDirectory = "$(System.ArtifactsDirectory)\thirdPartySigned"
|
|
|
|
$null = New-Item -ItemType Directory -Path $signedFilesDirectory -Force
|
|
|
|
|
|
|
|
$missingSignatures | ForEach-Object {
|
|
|
|
Copy-Item -Path $_ -Destination $filesToSignDirectory
|
|
|
|
}
|
|
|
|
|
|
|
|
displayName: Create ThirdParty Signing Folder
|
2020-05-05 21:35:03 +02:00
|
|
|
condition: and(succeeded(), eq(variables['SHOULD_SIGN'], 'true'))
|
|
|
|
|
2020-11-11 21:09:55 +01:00
|
|
|
- template: EsrpSign.yml@ComplianceRepo
|
|
|
|
parameters:
|
|
|
|
buildOutputPath: $(System.ArtifactsDirectory)\thirdPartyToBeSigned
|
|
|
|
signOutputPath: $(System.ArtifactsDirectory)\thirdPartySigned
|
|
|
|
certificateId: "CP-231522"
|
|
|
|
pattern: |
|
|
|
|
**\*.dll
|
|
|
|
useMinimatch: true
|
2020-12-09 23:51:43 +01:00
|
|
|
shouldSign: $(SHOULD_SIGN)
|
2020-11-11 21:09:55 +01:00
|
|
|
|
2020-05-05 21:35:03 +02:00
|
|
|
- powershell: |
|
2020-11-11 21:09:55 +01:00
|
|
|
Get-ChildItem '$(System.ArtifactsDirectory)\thirdPartySigned\*'
|
2020-05-05 21:35:03 +02:00
|
|
|
displayName: Captrue ThirdParty Signed files
|
|
|
|
condition: and(succeeded(), eq(variables['SHOULD_SIGN'], 'true'))
|
|
|
|
|
|
|
|
- powershell: |
|
|
|
|
Import-Module $(PowerShellRoot)/build.psm1 -Force
|
|
|
|
Import-Module $(PowerShellRoot)/tools/packaging -Force
|
2020-11-11 21:09:55 +01:00
|
|
|
$signedFilesPath = '$(System.ArtifactsDirectory)\thirdPartySigned'
|
2020-05-05 21:35:03 +02:00
|
|
|
$BuildPath = '$(System.ArtifactsDirectory)\$(SymbolsFolder)'
|
|
|
|
|
|
|
|
Update-PSSignedBuildFolder -BuildPath $BuildPath -SignedFilesPath $SignedFilesPath
|
|
|
|
displayName: Merge ThirdParty signed files with Build
|
|
|
|
condition: and(succeeded(), eq(variables['SHOULD_SIGN'], 'true'))
|
|
|
|
|
|
|
|
- powershell: |
|
|
|
|
Import-Module $(PowerShellRoot)/build.psm1 -Force
|
|
|
|
Import-Module $(PowerShellRoot)/tools/packaging -Force
|
|
|
|
|
2020-02-14 17:44:43 +01:00
|
|
|
$destFolder = '$(System.ArtifactsDirectory)\signedZip'
|
|
|
|
$BuildPath = '$(System.ArtifactsDirectory)\$(SymbolsFolder)'
|
|
|
|
|
|
|
|
New-Item -ItemType Directory -Path $destFolder -Force
|
|
|
|
|
2020-05-05 21:35:03 +02:00
|
|
|
$BuildPackagePath = New-PSBuildZip -BuildPath $BuildPath -DestinationFolder $destFolder
|
2020-02-14 17:44:43 +01:00
|
|
|
|
|
|
|
Write-Verbose -Verbose "New-PSSignedBuildZip returned `$BuildPackagePath as: $BuildPackagePath"
|
|
|
|
Write-Host "##vso[artifact.upload containerfolder=results;artifactname=results]$BuildPackagePath"
|
|
|
|
|
|
|
|
$vstsCommandString = "vso[task.setvariable variable=BuildPackagePath]$BuildPackagePath"
|
|
|
|
Write-Host ("sending " + $vstsCommandString)
|
|
|
|
Write-Host "##$vstsCommandString"
|
|
|
|
displayName: Compress signed files
|
|
|
|
|
|
|
|
- powershell: |
|
|
|
|
$runtime = switch ($env:Architecture)
|
|
|
|
{
|
|
|
|
"x64" { "win7-x64" }
|
|
|
|
"x86" { "win7-x86" }
|
|
|
|
"arm" { "win-arm"}
|
|
|
|
"arm64" { "win-arm64" }
|
|
|
|
"fxdependent" { "fxdependent" }
|
|
|
|
"fxdependentWinDesktop" { "fxdependent-win-desktop" }
|
|
|
|
}
|
|
|
|
|
|
|
|
$signedPkg = "$(BuildPackagePath)"
|
|
|
|
|
|
|
|
Write-Verbose -Verbose -Message "signedPkg = $signedPkg"
|
|
|
|
|
|
|
|
$(PowerShellRoot)/tools/releaseBuild/Images/microsoft_powershell_windowsservercore/PowerShellPackage.ps1 -BuildZip $signedPkg -location '$(PowerShellRoot)' -destination '$(System.ArtifactsDirectory)\pkgSigned' -Runtime $runtime -ReleaseTag '$(ReleaseTagVar)'
|
|
|
|
displayName: 'Build Windows Universal - $(Architecture) Package'
|
|
|
|
|
|
|
|
- powershell: |
|
|
|
|
Get-ChildItem '$(System.ArtifactsDirectory)\pkgSigned' | ForEach-Object {
|
|
|
|
$packagePath = $_.FullName
|
|
|
|
Write-Host "Uploading $packagePath"
|
|
|
|
Write-Host "##vso[artifact.upload containerfolder=signed;artifactname=signed]$packagePath"
|
|
|
|
}
|
|
|
|
displayName: Upload packages
|
|
|
|
|
|
|
|
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
|
|
|
|
displayName: 'Component Detection'
|
|
|
|
inputs:
|
|
|
|
sourceScanPath: '$(Build.SourcesDirectory)'
|
|
|
|
snapshotForceEnabled: true
|
|
|
|
|
|
|
|
- powershell: |
|
|
|
|
if ((Test-Path "\PowerShell")) {
|
|
|
|
Remove-Item -Path "\PowerShell" -Force -Recurse -Verbose
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Write-Verbose -Verbose -Message "No cleanup required."
|
|
|
|
}
|
|
|
|
|
|
|
|
if((Test-Path "${env:ProgramFiles(x86)}\WiX Toolset xcopy")) {
|
|
|
|
Write-Verbose -Verbose "Cleaning up Wix tools"
|
|
|
|
Remove-Item "${env:ProgramFiles(x86)}\WiX Toolset xcopy" -Recurse -Force
|
|
|
|
}
|
|
|
|
displayName: Clean up local Clone
|
|
|
|
condition: always()
|