From 61465c9c6ddf9c67b28fe6d2f02caeacd0dd0d25 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Mon, 8 Aug 2022 11:56:01 -0700 Subject: [PATCH 01/18] Update release pipeline to use Approvals and automate some manual tasks (#17837) --- .../azureDevOps/releasePipeline.yml | 291 +++++++++++++++--- .../templates/release-CreateGitHubDraft.yml | 10 +- .../templates/release/approvalJob.yml | 4 + 3 files changed, 249 insertions(+), 56 deletions(-) diff --git a/tools/releaseBuild/azureDevOps/releasePipeline.yml b/tools/releaseBuild/azureDevOps/releasePipeline.yml index 970c4c88955..05b86ff3d20 100644 --- a/tools/releaseBuild/azureDevOps/releasePipeline.yml +++ b/tools/releaseBuild/azureDevOps/releasePipeline.yml @@ -12,6 +12,13 @@ resources: branches: - release/* + repositories: + - repository: Internal-PowerShellTeam-Tools + type: git + trigger: none + name: Internal-PowerShellTeam-Tools + ref: master + variables: - name: runCodesignValidationInjection value : false @@ -148,24 +155,97 @@ stages: dependsOn: [] displayName: Manual Validation jobs: - - deployment: ValidateWinPkg - displayName: Validate Windows Packages - pool: server - environment: PSReleaseWinPkgValidate + - template: templates/release/approvalJob.yml + parameters: + displayName: Validate Windows Packages + jobName: ValidateWinPkg + instructions: | + Validate zip and msipackages on Windows Server 2012 R2 - - deployment: ValidateLinuxPkg - displayName: Validate Linux Packages - pool: server - environment: PSReleaseLinuxPkgValidate + - template: templates/release/approvalJob.yml + parameters: + displayName: Validate OSX Packages + jobName: ValidateOsxPkg + instructions: | + Validate tar.gz package on osx-arm64 - stage: ReleaseAutomation displayName: Release Automation dependsOn: [] jobs: - - deployment: ReleaseAutomationKickOff - displayName: Kick off release ReleaseAutomation - pool: server - environment: PSReleaseAutomationKickOff + - job: KickOffRA + displayName: Kickoff Release Automation + + pool: + name: PowerShell1ES + demands: + - ImageOverride -equals PSMMS2019-Secure + + steps: + - checkout: Internal-PowerShellTeam-Tools + - task: DownloadPipelineArtifact@2 + inputs: + source: specific + project: PowerShellCore + pipeline: '696' + preferTriggeringPipeline: true + runVersion: latestFromBranch + runBranch: '$(Build.SourceBranch)' + artifact: metadata + path: '$(Pipeline.Workspace)/releasePipeline/metadata' + + - pwsh: | + Get-ChildItem -Path $(Build.SourcesDirectory) + Import-Module $(Build.SourcesDirectory)\ReleaseTools\AzDO -Force + Set-AzDoAuthToken -Token $(RELEASEAUTOMATIONPAT) + Set-AzDoProjectInfo -ProjectOwner PowerShell-Rel -ProjectName Release-Automation + $packageBuildID = $(resources.pipeline.releasePipeline.runID) + $metadata = Get-Content -Raw -Path '$(Pipeline.Workspace)/releasePipeline/metadata/release.json' | ConvertFrom-Json + $buildInvocationInfo = Start-AzDOBuild -BuildDefinitionId 10 -BuildArguments @{ POWERSHELL_PACKAGE_BUILD_BUILDID = $packageBuildID } -Tag $metadata.ReleaseVersion, 'InProgress' -PassThru + Write-Verbose -Verbose "Kicked off release automation:`n$($buildInvocationInfo | Out-String)" + $status = $buildInvocationInfo | Wait-AzDOBuildStatus -Status Completed -timeoutMinutes 240 + if ($status.result -ne 'Succeeded') { + Write-Verbose "There are errors in release automation tests. Please triage failures." + } + + - template: templates/release/approvalJob.yml + parameters: + displayName: Triage Release Automation Results + jobName: TriageRA + dependsOnJob: KickOffRA + instructions: | + Validate all the test failures and continue when signed off + + - job: MarkRASignOff + displayName: Mark release automation signoff + dependsOn: TriageRA + + pool: + name: PowerShell1ES + demands: + - ImageOverride -equals PSMMS2019-Secure + + steps: + - checkout: Internal-PowerShellTeam-Tools + - task: DownloadPipelineArtifact@2 + inputs: + source: specific + project: PowerShellCore + pipeline: '696' + preferTriggeringPipeline: true + runVersion: latestFromBranch + runBranch: '$(Build.SourceBranch)' + artifact: metadata + path: '$(Pipeline.Workspace)/releasePipeline/metadata' + + - pwsh: | + Import-Module $(Build.SourcesDirectory)\ReleaseTools\AzDO -Force + Set-AzDoAuthToken -Token $(RELEASEAUTOMATIONPAT) + Set-AzDoProjectInfo -ProjectOwner PowerShell-Rel -ProjectName Release-Automation + $metadata = Get-Content -Raw -Path '$(Pipeline.Workspace)/releasePipeline/metadata/release.json' | ConvertFrom-Json + $azDOBuild = Get-AzDOBuild -buildDefinitionId 10 -MaximumResult 100 | Where-Object { $_.tags -in $metadata.ReleaseVersion } + $azDoBuild | Remove-AzDOBuildTag -tag 'InProgress' -Pass | Add-AzDOBuildTag -tag 'SignedOff' + displayName: Signoff Release-Automation run - stage: GitHubDraftRelease displayName: Create GitHub draft release @@ -220,11 +300,6 @@ stages: displayName: GitHub manual tasks dependsOn: GitHubDraftRelease jobs: - - deployment: UpdateChangeLog - displayName: Update Change Log - pool : server - environment: PSReleaseUpdateChangeLog - - deployment: PushTag displayName: Push Git Tag pool : server @@ -234,6 +309,7 @@ stages: displayName: Make GitHub Draft public pool : server environment: PSReleaseDraftPublic + dependsOn: PushTag - stage: PublishPackages displayName: Publish packages @@ -266,10 +342,12 @@ stages: displayName: Ensure changes are in GH master dependsOn: PublishPackages jobs: - - deployment: MergeToMaster - displayName: Make sure changes are in master - pool: server - environment: PSReleaseChangesToMaster + - template: templates/release/approvalJob.yml + parameters: + displayName: Make sure changes are in master + jobName: MergeToMaster + instructions: | + Make sure that changes README.md and metadata.json are merged into master on GitHub. - stage: ReleaseDocker displayName: Release Docker @@ -290,19 +368,76 @@ stages: # adds newPwshOrgName (exists in new and old org) - group: PowerShellRelease jobs: - - template: templates/release/approvalJob.yml - parameters: - displayName: Start the release build - jobName: SnapStart - instructions: | - Start the snap pipeline at: https://dev.azure.com/$(newPwshOrgName)/PowerShell/_build?definitionId=49&_a=summary + - job: KickoffSnap + displayName: Kickoff Snap build + + pool: + name: PowerShell1ES + demands: + - ImageOverride -equals PSMMS2019-Secure + + steps: + - checkout: Internal-PowerShellTeam-Tools + - task: DownloadPipelineArtifact@2 + inputs: + source: specific + project: PowerShellCore + pipeline: '696' + preferTriggeringPipeline: true + runVersion: latestFromBranch + runBranch: '$(Build.SourceBranch)' + artifact: metadata + path: '$(Pipeline.Workspace)/releasePipeline/metadata' + - pwsh: | + Import-Module $(Build.SourcesDirectory)\ReleaseTools\AzDO -Force + Set-AzDoAuthToken -Token $(RELEASEAUTOMATIONPAT) + Set-AzDoProjectInfo -ProjectOwner PowerShell-Rel -ProjectName PowerShell + $metadata = Get-Content -Raw -Path '$(Pipeline.Workspace)/releasePipeline/metadata/release.json' | ConvertFrom-Json + $buildInvocationInfo = Start-AzDOBuild -BuildDefinitionId 49 -Tag $metadata.ReleaseVersion, 'InProgress' -PassThru + Write-Verbose -Verbose "Kicked off snap build: $($buildInvocationInfo.WebUrl)" + $status = $buildInvocationInfo | Wait-AzDOBuildStatus -Status Completed -timeoutMinutes 60 + if ($status.result -ne 'Succeeded') { + throw "There are errors in snap build!!" + } + - template: templates/release/approvalJob.yml parameters: displayName: Approve the release jobName: SnapEnd + dependsOnJob: KickoffSnap instructions: | Once the build is finished, approve the release of all channels. + - job: MarkSnapSignOff + displayName: Mark release automation signoff + dependsOn: SnapEnd + + pool: + name: PowerShell1ES + demands: + - ImageOverride -equals PSMMS2019-Secure + + steps: + - checkout: Internal-PowerShellTeam-Tools + - task: DownloadPipelineArtifact@2 + inputs: + source: specific + project: PowerShellCore + pipeline: '696' + preferTriggeringPipeline: true + runVersion: latestFromBranch + runBranch: '$(Build.SourceBranch)' + artifact: metadata + path: '$(Pipeline.Workspace)/releasePipeline/metadata' + - pwsh: | + Import-Module $(Build.SourcesDirectory)\ReleaseTools\AzDO -Force + Set-AzDoAuthToken -Token $(RELEASEAUTOMATIONPAT) + Set-AzDoProjectInfo -ProjectOwner PowerShell-Rel -ProjectName PowerShell + $metadata = Get-Content -Raw -Path '$(Pipeline.Workspace)/releasePipeline/metadata/release.json' | ConvertFrom-Json + $azDOBuild = Get-AzDOBuild -buildDefinitionId 49 -MaximumResult 100 | Where-Object { $_.tags -in $metadata.ReleaseVersion } + $azDoBuild | Remove-AzDOBuildTag -tag 'InProgress' -Pass | Add-AzDOBuildTag -tag 'SignedOff' + displayName: Signoff Release-Automation run + - stage: ReleaseToMU displayName: Release to MU dependsOn: @@ -319,28 +454,38 @@ stages: dependsOn: GitHubManualTasks displayName: Update DotNet SDK Docker images jobs: - - deployment: DotnetSDkDocker - displayName: Update .NET SDK docker images - pool: server - environment: PSReleaseUpdateDotnetDocker + - template: templates/release/approvalJob.yml + parameters: + displayName: Update .NET SDK docker images + jobName: DotnetDocker + instructions: | + Create PR for updating dotnet-docker images to use latest PowerShell version. + 1. Fork and clone https://github.com/dotnet/dotnet-docker.git + 2. git checkout upstream/nightly -b updatePS + 3. dotnet run --project .\eng\update-dependencies\ -- --product-version powershell= --compute-shas + 4. create PR targeting nightly branch - stage: UpdateWinGet dependsOn: GitHubManualTasks displayName: Add manifest entry to winget jobs: - - deployment: UpdateWinGet - displayName: Add manifest entry to winget - pool: server - environment: PSReleaseUpdateWinGet + - template: templates/release/approvalJob.yml + parameters: + displayName: Add manifest entry to winget + jobName: UpdateWinGet + instructions: | + This is typically done by the community 1-2 days after the release. - stage: PublishMsix dependsOn: GitHubManualTasks displayName: Publish MSIX to store jobs: - - deployment: PublishMsix - displayName: Publish the MSIX Bundle package to store - pool: server - environment: PSReleasePublishMsix + - template: templates/release/approvalJob.yml + parameters: + displayName: Publish the MSIX Bundle package to store + jobName: PublishMsix + instructions: | + Ask Steve to release MSIX bundle package to Store - stage: BuildInfoJson dependsOn: GitHubManualTasks @@ -367,10 +512,50 @@ stages: dependsOn: GitHubManualTasks displayName: Release VPack jobs: - - deployment: ReleaseVPackManual - displayName: Release VPack - pool: server - environment: PSReleaseVpack + - job: KickoffvPack + displayName: Kickoff vPack build + + pool: + name: PowerShell1ES + demands: + - ImageOverride -equals PSMMS2019-Secure + + steps: + - checkout: Internal-PowerShellTeam-Tools + - task: DownloadPipelineArtifact@2 + inputs: + source: specific + project: PowerShellCore + pipeline: '696' + preferTriggeringPipeline: true + runVersion: latestFromBranch + runBranch: '$(Build.SourceBranch)' + artifact: metadata + path: '$(Pipeline.Workspace)/releasePipeline/metadata' + + - pwsh: | + Import-Module $(Build.SourcesDirectory)\ReleaseTools\AzDO -Force + Set-AzDoAuthToken -Token $(MSCODEHUBPAT) + Set-AzDoProjectInfo -ProjectOwner mscodehub -ProjectName PowerShellCore + $metadata = Get-Content -Raw -Path '$(Pipeline.Workspace)/releasePipeline/metadata/release.json' | ConvertFrom-Json + $releaseVersion = $metadata.ReleaseVersion -replace '^v','' + $semanticVersion = [System.Management.Automation.SemanticVersion]$releaseVersion + $isPreview = $semanticVersion.PreReleaseLabel -ne $null + + if (-not $isPreview) { + $buildInvocationInfo = Start-AzDOBuild -BuildDefinitionId 1238 -Tag $metadata.ReleaseVersion, 'InProgress' -PassThru + Write-Verbose -Verbose "Kicked off vPack build: $($buildInvocationInfo.WebUrl)" + $status = $buildInvocationInfo | Wait-AzDOBuildStatus -Status Completed -timeoutMinutes 60 + if ($status.result -ne 'Succeeded') { + throw "There are errors in snap build!!" + } + else { + $buildInvocationInfo | Remove-AzDOBuildTag -tag 'InProgress' -Pass | Add-AzDOBuildTag -tag 'SignedOff' + } + } + else { + Write-Verbose -Verbose "This is a preview release with version: $semanticVersion skipping releasing vPack" + } - stage: ReleaseDeps dependsOn: GitHubManualTasks @@ -389,12 +574,16 @@ stages: - ChangesToMaster - ReleaseDeps jobs: - - deployment: RetainBuild - displayName: Retain Build - pool: server - environment: PSReleaseRetainBuild + - template: templates/release/approvalJob.yml + parameters: + displayName: Retain Build + jobName: RetainBuild + instructions: | + Retain the build - - deployment: DeleteBranch - displayName: Delete release branch - pool: server - environment: PSReleaseDeleteBranch + - template: templates/release/approvalJob.yml + parameters: + displayName: Delete release branch + jobName: DeleteBranch + instructions: | + Delete release diff --git a/tools/releaseBuild/azureDevOps/templates/release-CreateGitHubDraft.yml b/tools/releaseBuild/azureDevOps/templates/release-CreateGitHubDraft.yml index dc7cf126630..0c61ac47219 100644 --- a/tools/releaseBuild/azureDevOps/templates/release-CreateGitHubDraft.yml +++ b/tools/releaseBuild/azureDevOps/templates/release-CreateGitHubDraft.yml @@ -66,17 +66,17 @@ steps: "preview.md" } else { - $semanticVersion.Major.ToString() + "." + $semanticVersion.Minor.ToString() + ".md" + $semanticVersion.Major + "." + $semanticVersion.Minor + ".md" } - $filePath = "$env:BUILD_SOURCESDIRECTORY/CHANGELOG/$fileName" + $filePath = $env:BUILD_SOURCESDIRECTORY/CHANGELOG/$fileName Write-Verbose -Verbose "Selected Log file: $filePath" if (-not (Test-Path $filePath)) { throw "$filePath not found" } - $changelog = Get-Content -Path $filePath + $changelog = Get-Content -Raw -Path $filePath $startPattern = "^## \[" + ([regex]::Escape($releaseVersion)) + "\]" $endPattern = "^## \[{0}\.{1}\.{2}*" -f $semanticVersion.Major, $semanticVersion.Minor, $semanticVersion.Patch @@ -85,9 +85,9 @@ steps: if ($_ -match $startPattern) { $outputLine = $true } elseif ($_ -match $endPattern) { $outputLine = $false } if ($outputLine) { $_} - } | Out-String + } Write-Verbose -Verbose "Selected content: `n$clContent" - Publish-ReleaseDraft -Tag '$(ReleaseTag)' -Name '$(ReleaseTag) Release of PowerShell' -Description $clContent -User PowerShell -Repository PowerShell -PackageFolder $(PackagesRoot) -Token $(GitHubReleasePat) + Publish-ReleaseDraft -Tag '$(ReleaseTag)' -Name '$(ReleaseTag) Release of PowerShell' -Description $clContent -User PowerShell -Repository PowerShell -PackageFolder $(System.ArtifactsDirectory) -Token $(GitHubReleasePat) displayName: Publish Release Draft diff --git a/tools/releaseBuild/azureDevOps/templates/release/approvalJob.yml b/tools/releaseBuild/azureDevOps/templates/release/approvalJob.yml index 8404e64e0ef..b34cc4c75b6 100644 --- a/tools/releaseBuild/azureDevOps/templates/release/approvalJob.yml +++ b/tools/releaseBuild/azureDevOps/templates/release/approvalJob.yml @@ -16,9 +16,13 @@ parameters: values: - resume - reject + - name: dependsOnJob + type: string + default: '' jobs: - job: ${{ parameters.jobName }} + dependsOn: ${{ parameters.dependsOnJob }} displayName: ${{ parameters.displayName }} pool: server timeoutInMinutes: 4320 # job times out in 3 days From 20f62f44207717b9f51a8b3bc6f96cab5c319f73 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Thu, 16 Feb 2023 15:23:12 -0800 Subject: [PATCH 02/18] Add URL for all distributions (#19159) * Add URL for all distributions * Make url compatible --- tools/packages.microsoft.com/mapping.json | 79 ++++++++++++++++------- 1 file changed, 55 insertions(+), 24 deletions(-) diff --git a/tools/packages.microsoft.com/mapping.json b/tools/packages.microsoft.com/mapping.json index 8bb238e1e8f..9ae06c5f1b8 100644 --- a/tools/packages.microsoft.com/mapping.json +++ b/tools/packages.microsoft.com/mapping.json @@ -1,58 +1,89 @@ { - "Packages" : [ + "Packages": [ { "url": "microsoft-centos8-prod", - "distribution" : ["centos"], - "PackageFormat" : "PACKAGE_NAME-POWERSHELL_RELEASE-1.rh.x86_64.rpm" + "distribution": [ + "centos" + ], + "PackageFormat": "PACKAGE_NAME-POWERSHELL_RELEASE-1.rh.x86_64.rpm" }, { "url": "microsoft-rhel8.0-prod", - "distribution" : ["trusty"], - "PackageFormat" : "PACKAGE_NAME-POWERSHELL_RELEASE-1.rh.x86_64.rpm" + "distribution": [ + "trusty" + ], + "PackageFormat": "PACKAGE_NAME-POWERSHELL_RELEASE-1.rh.x86_64.rpm" }, { "url": "microsoft-rhel7.3-prod", - "distribution" : ["trusty"], - "PackageFormat" : "PACKAGE_NAME-POWERSHELL_RELEASE-1.rh.x86_64.rpm" + "distribution": [ + "trusty" + ], + "PackageFormat": "PACKAGE_NAME-POWERSHELL_RELEASE-1.rh.x86_64.rpm" }, { "url": "cbl-mariner-2.0-prod-Microsoft-x86_64", - "distribution" : ["bionic"], - "PackageFormat" : "PACKAGE_NAME-POWERSHELL_RELEASE-1.cm.x86_64.rpm", - "channel" : "stable" + "distribution": [ + "bionic" + ], + "PackageFormat": "PACKAGE_NAME-POWERSHELL_RELEASE-1.cm.x86_64.rpm", + "channel": "stable" }, { "url": "cbl-mariner-2.0-preview-Microsoft-x86_64", - "distribution" : ["bionic"], - "PackageFormat" : "PACKAGE_NAME-POWERSHELL_RELEASE-1.cm.x86_64.rpm", - "channel" : "preview" + "distribution": [ + "bionic" + ], + "PackageFormat": "PACKAGE_NAME-POWERSHELL_RELEASE-1.cm.x86_64.rpm", + "channel": "preview" }, { - "distribution" : ["stretch"], - "PackageFormat" : "PACKAGE_NAME_POWERSHELL_RELEASE-1.deb_amd64.deb" + "url": "microsoft-debian-stretch-prod", + "distribution": [ + "stretch" + ], + "PackageFormat": "PACKAGE_NAME_POWERSHELL_RELEASE-1.deb_amd64.deb" }, { - "distribution" : ["buster"], - "PackageFormat" : "PACKAGE_NAME_POWERSHELL_RELEASE-1.deb_amd64.deb" + "url": "microsoft-debian-buster-prod", + "distribution": [ + "buster" + ], + "PackageFormat": "PACKAGE_NAME_POWERSHELL_RELEASE-1.deb_amd64.deb" }, { - "distribution" : ["bionic"], - "PackageFormat" : "PACKAGE_NAME_POWERSHELL_RELEASE-1.deb_amd64.deb" + "url": "microsoft-ubuntu-bionic-prod", + "distribution": [ + "bionic" + ], + "PackageFormat": "PACKAGE_NAME_POWERSHELL_RELEASE-1.deb_amd64.deb" }, { - "distribution" : ["jammy"], - "PackageFormat" : "PACKAGE_NAME_POWERSHELL_RELEASE-1.deb_amd64.deb" + "url": "microsoft-ubuntu-jammy-prod", + "distribution": [ + "jammy" + ], + "PackageFormat": "PACKAGE_NAME_POWERSHELL_RELEASE-1.deb_amd64.deb" }, { - "distribution": ["focal"], + "url": "microsoft-ubuntu-focal-prod", + "distribution": [ + "focal" + ], "PackageFormat": "PACKAGE_NAME_POWERSHELL_RELEASE-1.deb_amd64.deb" }, { - "distribution": ["xenial"], + "url": "microsoft-ubuntu-xenial-prod", + "distribution": [ + "xenial" + ], "PackageFormat": "PACKAGE_NAME_POWERSHELL_RELEASE-1.deb_amd64.deb" }, { - "distribution": ["bullseye"], + "url": "microsoft-debian-bullseye-prod", + "distribution": [ + "bullseye" + ], "PackageFormat": "PACKAGE_NAME_POWERSHELL_RELEASE-1.deb_amd64.deb" } ] From 347dfa3ad11e1bd3862c26c02acb0a1907022433 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Thu, 9 Mar 2023 11:24:34 -0800 Subject: [PATCH 03/18] Use reference assemblies generated by dotnet (#19302) --- tools/packaging/packaging.psm1 | 55 ++++++++-------- .../azureDevOps/templates/nuget-pkg-sbom.yml | 66 ++++++++++++++++++- .../azureDevOps/templates/nuget.yml | 9 --- 3 files changed, 90 insertions(+), 40 deletions(-) diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index 8d45ecab1ea..42f59ce814a 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -1967,8 +1967,11 @@ Path to source folder containing Windows framework dependent assemblies. .PARAMETER LinuxFxdBinPath Path to source folder containing Linux framework dependent assemblies. -.PARAMETER GenAPIToolPath -Path to the GenAPI.exe tool. +.PARAMETER RefAssemblyPath +Path to the reference assemblies. + +.PARAMETER CGManifestPath +Path to the CGManifest.json file. #> function New-ILNugetPackageSource { @@ -1990,10 +1993,11 @@ function New-ILNugetPackageSource [string] $LinuxFxdBinPath, [Parameter(Mandatory = $true)] - [string] $GenAPIToolPath, + [string] $RefAssemblyPath, [Parameter(Mandatory = $true)] [string] $CGManifestPath + ) if (! $Environment.IsWindows) @@ -2026,11 +2030,8 @@ function New-ILNugetPackageSource "Microsoft.WSMan.Management.dll", "Microsoft.WSMan.Runtime.dll") - $refBinPath = New-TempFolder $SnkFilePath = "$RepoRoot\src\signing\visualstudiopublic.snk" - New-ReferenceAssembly -linux64BinPath $LinuxFxdBinPath -RefAssemblyDestinationPath $refBinPath -RefAssemblyVersion $PackageVersion -SnkFilePath $SnkFilePath -GenAPIToolPath $GenAPIToolPath - if (! (Test-Path $PackagePath)) { $null = New-Item -Path $PackagePath -ItemType Directory } @@ -2044,7 +2045,7 @@ function New-ILNugetPackageSource #region ref $refFolder = New-Item (Join-Path $filePackageFolder.FullName "ref/$script:netCoreRuntime") -ItemType Directory -Force - CopyReferenceAssemblies -assemblyName $fileBaseName -refBinPath $refBinPath -refNugetPath $refFolder -assemblyFileList $fileList -winBinPath $WinFxdBinPath + CopyReferenceAssemblies -assemblyName $fileBaseName -refBinPath $RefAssemblyPath -refNugetPath $refFolder -assemblyFileList $fileList -winBinPath $WinFxdBinPath #endregion ref $packageRuntimesFolderPath = $packageRuntimesFolder.FullName @@ -2109,10 +2110,6 @@ function New-ILNugetPackageSource } $deps = New-FileDependencies -FileBaseName $fileBaseName -PackageVersion $PackageVersion New-CGManifest -FilePath (Join-Path -Path $CGManifestPath -ChildPath "CGManifest.json") -Dependencies $deps - - if (Test-Path $refBinPath) { - Remove-Item $refBinPath -Recurse -Force -ErrorAction SilentlyContinue - } } <# @@ -2199,33 +2196,33 @@ function CopyReferenceAssemblies $supportedRefList = @( "Microsoft.PowerShell.Commands.Utility", - "Microsoft.PowerShell.ConsoleHost") + "Microsoft.PowerShell.ConsoleHost", + "Microsoft.PowerShell.Commands.Management", + "Microsoft.PowerShell.Commands.Security", + "System.Management.Automation" + ) switch ($assemblyName) { - { $_ -in $supportedRefList } { - $refDll = Join-Path -Path $refBinPath -ChildPath "$assemblyName.dll" - $refDoc = Join-Path -Path $refBinPath -ChildPath "$assemblyName.xml" - Copy-Item $refDll, $refDoc -Destination $refNugetPath -Force - Write-Log "Copied file '$refDll' and '$refDoc' to '$refNugetPath'" - } - "Microsoft.PowerShell.SDK" { foreach ($asmFileName in $assemblyFileList) { - $refFile = Join-Path -Path $refBinPath -ChildPath $asmFileName - if (Test-Path -Path $refFile) { - $refDoc = Join-Path -Path $refBinPath -ChildPath ([System.IO.Path]::ChangeExtension($asmFileName, "xml")) - Copy-Item $refFile, $refDoc -Destination $refNugetPath -Force - Write-Log "Copied file '$refFile' and '$refDoc' to '$refNugetPath'" + $fileName = [System.IO.Path]::GetFileNameWithoutExtension($asmFileName) + + if ($fileName -in $supportedRefList) { + $refFile = Join-Path -Path $refBinPath -ChildPath $asmFileName + if (Test-Path -Path $refFile) { + $refDoc = Join-Path -Path $refBinPath -ChildPath ([System.IO.Path]::ChangeExtension($asmFileName, "xml")) + Copy-Item $refFile, $refDoc -Destination $refNugetPath -Force + Write-Log "Copied file '$refFile' and '$refDoc' to '$refNugetPath'" + } } } } default { - $ref_SMA = Join-Path -Path $refBinPath -ChildPath System.Management.Automation.dll - $ref_doc = Join-Path -Path $refBinPath -ChildPath System.Management.Automation.xml - $self_ref_doc = Join-Path -Path $winBinPath -ChildPath "$assemblyName.xml" - Copy-Item $ref_SMA, $ref_doc, $self_ref_doc -Destination $refNugetPath -Force - Write-Log "Copied file '$ref_SMA' and '$ref_doc' to '$refNugetPath'" + $refDll = Join-Path -Path $refBinPath -ChildPath "$assemblyName.dll" + $refDoc = Join-Path -Path $refBinPath -ChildPath "$assemblyName.xml" + Copy-Item $refDll, $refDoc -Destination $refNugetPath -Force + Write-Log "Copied file '$refDll' and '$refDoc' to '$refNugetPath'" } } } diff --git a/tools/releaseBuild/azureDevOps/templates/nuget-pkg-sbom.yml b/tools/releaseBuild/azureDevOps/templates/nuget-pkg-sbom.yml index fe8c1a872ff..f0a033fd9e4 100644 --- a/tools/releaseBuild/azureDevOps/templates/nuget-pkg-sbom.yml +++ b/tools/releaseBuild/azureDevOps/templates/nuget-pkg-sbom.yml @@ -3,7 +3,6 @@ parameters: - name: PackagePath - name: WinFxdPath - name: LinuxFxdPath - - name: GenAPIToolPath - name: ListOfFiles type: object default: @@ -20,6 +19,69 @@ parameters: - System.Management.Automation.dll steps: + +- pwsh: | + Import-Module "$env:REPOROOT/build.psm1" -Force + Start-PSBootstrap + + $sharedModules = @('Microsoft.PowerShell.Commands.Management', + 'Microsoft.PowerShell.Commands.Utility', + 'Microsoft.PowerShell.ConsoleHost', + 'Microsoft.PowerShell.Security', + 'System.Management.Automation' + ) + + $winOnlyModules = @('Microsoft.Management.Infrastructure.CimCmdlets', + 'Microsoft.PowerShell.Commands.Diagnostics', + 'Microsoft.PowerShell.CoreCLR.Eventing', + 'Microsoft.WSMan.Management', + 'Microsoft.WSMan.Runtime' + ) + + $refAssemblyFolder = Join-Path '$(System.ArtifactsDirectory)' 'RefAssembly' + $null = New-Item -Path $refAssemblyFolder -Force -Verbose -Type Directory + + Start-PSBuild -Clean -Runtime linux-x64 -Configuration Release + + $sharedModules | Foreach-Object { + $refFile = Get-ChildItem -Path "$env:REPOROOT\src\$_\obj\Release\net8.0\refint\$_.dll" + Write-Verbose -Verbose "RefAssembly: $refFile" + Copy-Item -Path $refFile -Destination "$refAssemblyFolder\$_.dll" -Verbose + $refDoc = "$env:REPOROOT\src\$_\bin\Release\net8.0\$_.xml" + if (-not (Test-Path $refDoc)) { + Write-Warning "$refDoc not found" + Get-ChildItem -Path "$env:REPOROOT\src\$_\bin\Release\net8.0\" | Out-String | Write-Verbose -Verbose + } + else { + Copy-Item -Path $refDoc -Destination "$refAssemblyFolder\$_.xml" -Verbose + } + } + + Start-PSBuild -Clean -Runtime win7-x64 -Configuration Release + + $winOnlyModules | Foreach-Object { + $refFile = Get-ChildItem -Path "$env:REPOROOT\src\$_\obj\Release\net8.0\refint\*.dll" + Write-Verbose -Verbose 'RefAssembly: $refFile' + Copy-Item -Path $refFile -Destination "$refAssemblyFolder\$_.dll" -Verbose + $refDoc = "$env:REPOROOT\src\$_\bin\Release\net8.0\$_.xml" + if (-not (Test-Path $refDoc)) { + Write-Warning "$refDoc not found" + Get-ChildItem -Path "$env:REPOROOT\src\$_\bin\Release\net8.0" | Out-String | Write-Verbose -Verbose + } + else { + Copy-Item -Path $refDoc -Destination "$refAssemblyFolder\$_.xml" -Verbose + } + } + + Get-ChildItem $refAssemblyFolder -Recurse | Out-String | Write-Verbose -Verbose + + # Set RefAssemblyPath path variable + $vstsCommandString = "vso[task.setvariable variable=RefAssemblyPath]${refAssemblyFolder}" + Write-Host "sending " + $vstsCommandString + Write-Host "##$vstsCommandString" + + displayName: Build reference assemblies + - ${{ each value in parameters.ListOfFiles }}: - pwsh: | $FileName = '${{ value }}' @@ -45,7 +107,7 @@ steps: Import-Module -Name $env:REPOROOT\build.psm1 Import-Module -Name $env:REPOROOT\tools\packaging Find-DotNet - New-ILNugetPackageSource -File $FileName -PackagePath '${{ parameters.PackagePath }}' -PackageVersion '${{ parameters.PackageVersion }}' -WinFxdBinPath '${{ parameters.WinFxdPath }}' -LinuxFxdBinPath '${{ parameters.LinuxFxdPath }}' -GenAPIToolPath '${{ parameters.GenAPIToolPath }}' -CGManifestPath $CGManifestPath + New-ILNugetPackageSource -File $FileName -PackagePath '${{ parameters.PackagePath }}' -PackageVersion '${{ parameters.PackageVersion }}' -WinFxdBinPath '${{ parameters.WinFxdPath }}' -LinuxFxdBinPath '${{ parameters.LinuxFxdPath }}' -CGManifestPath $CGManifestPath -RefAssemblyPath $(RefAssemblyPath) displayName: 'Create NuGet Package source for single file' - template: Sbom.yml@ComplianceRepo diff --git a/tools/releaseBuild/azureDevOps/templates/nuget.yml b/tools/releaseBuild/azureDevOps/templates/nuget.yml index 67b7b2971dc..1d3fe2b9472 100644 --- a/tools/releaseBuild/azureDevOps/templates/nuget.yml +++ b/tools/releaseBuild/azureDevOps/templates/nuget.yml @@ -102,14 +102,6 @@ jobs: archiveFilePatterns: '$(System.ArtifactsDirectory)/packages/powershell-*-linux-x64-fxdependent.tar.gz' destinationFolder: '$(linuxFxdPath)' - - task: PkgESInstallNuGetToolsPackage@10 - displayName: 'Install package Microsoft.DotNet.BuildTools.GenAPI' - inputs: - packageName: Microsoft.DotNet.BuildTools.GenAPI - packageVersion: '1.0.0-beta-00081' - packageSources: 'https://nuget.org/api/v2' - installRoot: '$(GenAPIToolPath)' - - template: SetVersionVariables.yml parameters: ReleaseTagVar: $(ReleaseTagVar) @@ -126,7 +118,6 @@ jobs: PackagePath: $(PackagePath) WinFxdPath: $(winFxdPath) LinuxFxdPath: $(linuxFxdPath) - GenAPIToolPath: $(GenAPIToolPath) - pwsh: | Get-ChildItem $(linuxFxdPath) From 510461f0f68793c725f8db442ee8e8aabb976d30 Mon Sep 17 00:00:00 2001 From: Anam Navied Date: Mon, 13 Mar 2023 12:18:58 -0400 Subject: [PATCH 04/18] Add stage for symbols job in Release build (#18937) --- .../azureDevOps/releasePipeline.yml | 14 +++++ .../templates/release-PublishSymbols.yml | 51 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 tools/releaseBuild/azureDevOps/templates/release-PublishSymbols.yml diff --git a/tools/releaseBuild/azureDevOps/releasePipeline.yml b/tools/releaseBuild/azureDevOps/releasePipeline.yml index 05b86ff3d20..bd52a99b844 100644 --- a/tools/releaseBuild/azureDevOps/releasePipeline.yml +++ b/tools/releaseBuild/azureDevOps/releasePipeline.yml @@ -338,6 +338,20 @@ stages: steps: - template: templates/release-PublishPackageMsftCom.yml +- stage: PublishSymbols + displayName: Publish symbols + dependsOn: PublishPackages + jobs: + - job: PublishSymbol + + pool: + name: PowerShell1ES + demands: + - ImageOverride -equals PSMMS2019-Secure + + steps: + - template: templates/release-PublishSymbols.yml + - stage: ChangesToMaster displayName: Ensure changes are in GH master dependsOn: PublishPackages diff --git a/tools/releaseBuild/azureDevOps/templates/release-PublishSymbols.yml b/tools/releaseBuild/azureDevOps/templates/release-PublishSymbols.yml new file mode 100644 index 00000000000..db2cc86e259 --- /dev/null +++ b/tools/releaseBuild/azureDevOps/templates/release-PublishSymbols.yml @@ -0,0 +1,51 @@ +steps: +- task: DownloadPipelineArtifact@2 + inputs: + source: specific + project: PowerShellCore + pipeline: '696' + preferTriggeringPipeline: true + runVersion: latestFromBranch + runBranch: '$(Build.SourceBranch)' + artifact: results + path: '$(Pipeline.Workspace)\results' + itemPattern: | + **/* + !**/*signed.zip + +- pwsh: | + Write-Verbose -Verbose "Enumerating $(Pipeline.Workspace)\results" + $downloadedArtifacts = Get-ChildItem -Recurse "$(Pipeline.Workspace)\results" + $downloadedArtifacts + $expandedRoot = New-Item -Path "$(Pipeline.Workspace)/expanded" -ItemType Directory -Verbose + $symbolsRoot = New-Item -Path "$(Pipeline.Workspace)/symbols" -ItemType Directory -Verbose + + $downloadedArtifacts | ForEach-Object { + $destFolder = New-Item -Path "$expandedRoot/$($_.BaseName)/" -ItemType Directory -Verbose + Expand-Archive -Path $_.FullName -DestinationPath $destFolder -Force + + $symbolsZipFile = Join-Path -Path $destFolder -ChildPath "symbols.zip" + $symbolZipFileContents = New-Item -Path "$destFolder/Symbols-$($_.BaseName)" -ItemType Directory -Verbose + Expand-Archive -Path $symbolsZipFile -DestinationPath $symbolZipFileContents -Force + + $symbolsToPublish = New-Item -Path "$symbolsRoot/$($_.BaseName)" -ItemType Directory -Verbose + + Get-ChildItem -Path $symbolZipFileContents -Recurse -Filter '*.pdb' | ForEach-Object { + Copy-Item -Path $_.FullName -Destination $symbolsToPublish -Verbose + } + } + + Write-Verbose -Verbose "Enumerating $symbolsRoot" + Get-ChildItem -Path $symbolsRoot -Recurse + $vstsCommandString = "vso[task.setvariable variable=SymbolsPath]$symbolsRoot" + Write-Verbose -Message "$vstsCommandString" -Verbose + Write-Host -Object "##$vstsCommandString" + displayName: Expand and capture symbols folders +- task: PublishSymbols@2 + inputs: + symbolsFolder: '$(SymbolsPath)' + searchPattern: '**/*.pdb' + indexSources: false + publishSymbols: true + symbolServerType: teamServices + detailedLog: true From dd76e4721b9ae9c15c9710430ed04edcf400ac5f Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Mon, 13 Mar 2023 15:40:27 -0700 Subject: [PATCH 05/18] Test fixes for stabilizing tests (#19068) --- build.psm1 | 33 +++ experimental-feature-linux.json | 8 +- experimental-feature-windows.json | 8 +- test/powershell/Host/HostUtilities.Tests.ps1 | 8 + .../TabCompletion/TabCompletion.Tests.ps1 | 203 ++++++++++++++++-- .../NativeCommandProcessor.Tests.ps1 | 17 +- .../RemoteGetModule.Tests.ps1 | 2 +- .../RemoteImportModule.Tests.ps1 | 2 +- .../CertificateProvider.Tests.ps1 | 75 ++++++- .../CmsMessage.Tests.ps1 | 42 +++- .../certificateCommon.psm1 | 12 +- .../Format-Table.Tests.ps1 | 18 +- .../Implicit.Remoting.Tests.ps1 | 2 +- .../Get-ExperimentalFeature.Tests.ps1 | 2 +- .../RemoteSession.Disconnect.Tests.ps1 | 2 +- .../engine/Remoting/RunspacePool.Tests.ps1 | 12 +- .../Modules/HelpersCommon/HelpersCommon.psd1 | 4 + .../Modules/HelpersCommon/HelpersCommon.psm1 | 50 +++++ 18 files changed, 450 insertions(+), 50 deletions(-) diff --git a/build.psm1 b/build.psm1 index c05b7a79dfc..4dc2dbe34a9 100644 --- a/build.psm1 +++ b/build.psm1 @@ -1050,6 +1050,36 @@ function Get-PesterTag { $o } +# Function to build and publish the Microsoft.PowerShell.NamedPipeConnection module for +# testing PowerShell remote custom connections. +function Publish-CustomConnectionTestModule +{ + $sourcePath = "${PSScriptRoot}/test/tools/NamedPipeConnection" + $outPath = "${PSScriptRoot}/test/tools/NamedPipeConnection/out/Microsoft.PowerShell.NamedPipeConnection" + $publishPath = "${PSScriptRoot}/test/tools/Modules" + + Find-DotNet + + Push-Location -Path $sourcePath + try { + # Build the Microsoft.PowerShell.NamedPipeConnect module + ./build.ps1 -Clean -Build + + if (! (Test-Path -Path $outPath)) { + throw "Publish-CustomConnectionTestModule: Build failed. Output path does not exist: $outPath" + } + + # Publish the Microsoft.PowerShell.NamedPipeConnection module + Copy-Item -Path $outPath -Destination $publishPath -Recurse -Force + + # Clean up build artifacts + ./build.ps1 -Clean + } + finally { + Pop-Location + } +} + function Publish-PSTestTools { [CmdletBinding()] param( @@ -1099,6 +1129,9 @@ function Publish-PSTestTools { # `dotnet restore` on test project is not called if product projects have been restored unless -Force is specified. Copy-PSGalleryModules -Destination "${PSScriptRoot}/test/tools/Modules" -CsProjPath "$PSScriptRoot/test/tools/Modules/PSGalleryTestModules.csproj" -Force + + # Publish the Microsoft.PowerShell.NamedPipeConnection module + Publish-CustomConnectionTestModule } function Get-ExperimentalFeatureTests { diff --git a/experimental-feature-linux.json b/experimental-feature-linux.json index 12df4c5db5c..0ff0ef9c422 100644 --- a/experimental-feature-linux.json +++ b/experimental-feature-linux.json @@ -7,8 +7,8 @@ "PSLoadAssemblyFromNativeCode", "PSNativeCommandArgumentPassing", "PSNativeCommandErrorActionPreference", - "PSNativePSPathResolution", - "PSRemotingSSHTransportErrorHandling", - "PSStrictModeAssignment", - "PSSubsystemPluginModel" + "PSSubsystemPluginModel", + "PSModuleAutoLoadSkipOfflineFiles", + "PSFeedbackProvider", + "PSCommandWithArgs" ] diff --git a/experimental-feature-windows.json b/experimental-feature-windows.json index 12df4c5db5c..0ff0ef9c422 100644 --- a/experimental-feature-windows.json +++ b/experimental-feature-windows.json @@ -7,8 +7,8 @@ "PSLoadAssemblyFromNativeCode", "PSNativeCommandArgumentPassing", "PSNativeCommandErrorActionPreference", - "PSNativePSPathResolution", - "PSRemotingSSHTransportErrorHandling", - "PSStrictModeAssignment", - "PSSubsystemPluginModel" + "PSSubsystemPluginModel", + "PSModuleAutoLoadSkipOfflineFiles", + "PSFeedbackProvider", + "PSCommandWithArgs" ] diff --git a/test/powershell/Host/HostUtilities.Tests.ps1 b/test/powershell/Host/HostUtilities.Tests.ps1 index b5c65af97e6..1f064408e3c 100644 --- a/test/powershell/Host/HostUtilities.Tests.ps1 +++ b/test/powershell/Host/HostUtilities.Tests.ps1 @@ -35,6 +35,12 @@ Describe "InvokeOnRunspace method as nested command" -tags "Feature" { Describe "InvokeOnRunspace method on remote runspace" -tags "Feature","RequireAdminOnWindows" { BeforeAll { + $originalDefaultParameterValues = $PSDefaultParameterValues.Clone() + + if (Test-IsWinWow64) { + $global:PSDefaultParameterValues["it:skip"] = $true + return + } if ($IsWindows) { $script:remoteRunspace = New-RemoteRunspace @@ -46,6 +52,8 @@ Describe "InvokeOnRunspace method on remote runspace" -tags "Feature","RequireAd { $script:remoteRunspace.Dispose(); } + + $global:PSDefaultParameterValues = $originalDefaultParameterValues } It "Method should successfully invoke command on remote runspace" -Skip:(!$IsWindows) { diff --git a/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 b/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 index 2674a74a21a..04711abc7f5 100644 --- a/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 +++ b/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 @@ -301,6 +301,118 @@ Describe "TabCompletion" -Tags CI { $actual | Should -BeExactly $expected } + It 'ForEach-Object member completion results should include methods' { + $res = TabExpansion2 -inputScript '1..10 | ForEach-Object -MemberName ' + $res.CompletionMatches.CompletionText | Should -Contain "GetType" + } + + It 'Should not complete void instance members' { + $res = TabExpansion2 -inputScript '([void]("")).' + $res.CompletionMatches | Should -BeNullOrEmpty + } + + It 'Should complete custom constructor from class using the AST' { + $res = TabExpansion2 -inputScript 'class ConstructorTestClass{ConstructorTestClass ([string] $s){}};[ConstructorTestClass]::' + $res.CompletionMatches | Should -HaveCount 3 + $completionText = $res.CompletionMatches.CompletionText | Sort-Object + $completionText -join ' ' | Should -BeExactly 'Equals( new( ReferenceEquals(' + } + + It 'Should show multiple constructors in the tooltip' { + $res = TabExpansion2 -inputScript 'class ConstructorTestClass{ConstructorTestClass ([string] $s){}ConstructorTestClass ([int] $i){}ConstructorTestClass ([int] $i, [bool]$b){}};[ConstructorTestClass]::new' + $res.CompletionMatches | Should -HaveCount 1 + $completionText = $res.CompletionMatches.ToolTip + $completionText.replace("`r`n", [System.Environment]::NewLine).trim() + + $expected = @' +ConstructorTestClass(string s) +ConstructorTestClass(int i) +ConstructorTestClass(int i, bool b) +'@ + $expected.replace("`r`n", [System.Environment]::NewLine).trim() + $completionText.replace("`r`n", [System.Environment]::NewLine).trim() | Should -BeExactly $expected + } + + It 'Should complete parameter in param block' { + $res = TabExpansion2 -inputScript 'Param($Param1=(Get-ChildItem -))' -cursorColumn 30 + $res.CompletionMatches[0].CompletionText | Should -BeExactly '-Path' + } + + It 'Should complete member in param block' { + $res = TabExpansion2 -inputScript 'Param($Param1=($PSVersionTable.))' -cursorColumn 31 + $res.CompletionMatches[0].CompletionText | Should -BeExactly 'Count' + } + + It 'Should complete attribute argument in param block' { + $res = TabExpansion2 -inputScript 'Param([Parameter()]$Param1)' -cursorColumn 17 + $names = [Parameter].GetProperties() | Where-Object CanWrite | ForEach-Object Name + + $diffs = Compare-Object -ReferenceObject $res.CompletionMatches.CompletionText -DifferenceObject $names + $diffs | Should -BeNullOrEmpty + } + + It 'Should complete argument for second parameter' { + $res = TabExpansion2 -inputScript 'Get-ChildItem -Path $HOME -ErrorAction ' + $res.CompletionMatches[0].CompletionText | Should -BeExactly Break + } + + It 'Should complete argument with validateset attribute after comma' { + $TestString = 'function Test-ValidateSet{Param([ValidateSet("Cat","Dog")]$Param1,$Param2)};Test-ValidateSet -Param1 Dog, -Param2' + $res = TabExpansion2 -inputScript $TestString -cursorColumn ($TestString.LastIndexOf(',') + 1) + $res.CompletionMatches[0].CompletionText | Should -BeExactly Cat + } + + it 'Should complete "Value" parameter value in "Where-Object" for Enum property with no input' { + $res = TabExpansion2 -inputScript 'Get-Command | where-Object CommandType -eq ' + $res.CompletionMatches[0].CompletionText | Should -BeExactly Alias + } + + it 'Should complete "Value" parameter value in "Where-Object" for Enum property with partial input' { + $res = TabExpansion2 -inputScript 'Get-Command | where-Object CommandType -ne Ali' + $res.CompletionMatches[0].CompletionText | Should -BeExactly Alias + } + + it 'Should complete the right hand side of a comparison operator when left is an Enum with no input' { + $res = TabExpansion2 -inputScript 'Get-Command | Where-Object -FilterScript {$_.CommandType -like ' + $res.CompletionMatches[0].CompletionText | Should -BeExactly "'Alias'" + } + + it 'Should complete the right hand side of a comparison operator when left is an Enum with partial input' { + $TempVar = Get-Command + $res = TabExpansion2 -inputScript '$tempVar[0].CommandType -notlike "Ali"' + $res.CompletionMatches[0].CompletionText | Should -BeExactly "'Alias'" + } + + it 'Should complete the right hand side of a comparison operator when left is an Enum when cursor is on a newline' { + $res = TabExpansion2 -inputScript "Get-Command | Where-Object -FilterScript {`$_.CommandType -like`n" + $res.CompletionMatches[0].CompletionText | Should -BeExactly "'Alias'" + } + + it 'Should complete provider dynamic parameters with quoted path' { + $Script = if ($IsWindows) + { + 'Get-ChildItem -Path "C:\" -Director' + } + else + { + 'Get-ChildItem -Path "/" -Director' + } + $res = TabExpansion2 -inputScript $Script + $res.CompletionMatches[0].CompletionText | Should -BeExactly '-Directory' + } + + it 'Should complete dynamic parameters while providing values to non-string parameters' { + $res = TabExpansion2 -inputScript 'Get-Content -Path $HOME -Verbose:$false -' + $res.CompletionMatches.CompletionText | Should -Contain '-Raw' + } + + It 'Should enumerate types when completing member names for Select-Object' { + $TestString = '"Hello","World" | select-object ' + $res = TabExpansion2 -inputScript $TestString + $res | Should -HaveCount 1 + $res.CompletionMatches[0].CompletionText | Should -BeExactly 'Length' + } + Context "Format cmdlet's View paramter completion" { BeforeAll { $viewDefinition = @' @@ -832,9 +944,8 @@ Describe "TabCompletion" -Tags CI { } It "Tab completion UNC path" -Skip:(!$IsWindows) { - $homeDrive = $env:HOMEDRIVE.Replace(":", "$") - $beforeTab = "\\localhost\$homeDrive\wind" - $afterTab = "& '\\localhost\$homeDrive\Windows'" + $beforeTab = "\\localhost\ADMIN$\boo" + $afterTab = "& '\\localhost\ADMIN$\Boot'" $res = TabExpansion2 -inputScript $beforeTab -cursorColumn $beforeTab.Length $res.CompletionMatches.Count | Should -BeGreaterThan 0 $res.CompletionMatches[0].CompletionText | Should -BeExactly $afterTab @@ -1457,7 +1568,7 @@ dir -Recurse ` Context "Tab completion help test" { BeforeAll { - if ([System.Management.Automation.Platform]::IsWindows) { + if ($IsWindows) { $userHelpRoot = Join-Path $HOME "Documents/PowerShell/Help/" } else { $userModulesRoot = [System.Management.Automation.Platform]::SelectProductNameForDirectory([System.Management.Automation.Platform+XDG_Type]::USER_MODULES) @@ -1466,33 +1577,89 @@ dir -Recurse ` } It 'Should complete about help topic' { - $aboutHelpPathUserScope = Join-Path $userHelpRoot (Get-Culture).Name - $aboutHelpPathAllUsersScope = Join-Path $PSHOME (Get-Culture).Name + $helpName = "about_Splatting" + $helpFileName = "${helpName}.help.txt" + $inputScript = "get-help about_spla" + $culture = "en-US" + $aboutHelpPathUserScope = Join-Path $userHelpRoot $culture + $aboutHelpPathAllUsersScope = Join-Path $PSHOME $culture + $expectedCompletionCount = 0 ## If help content does not exist, tab completion will not work. So update it first. - $userScopeHelp = Test-Path (Join-Path $aboutHelpPathUserScope "about_Splatting.help.txt") - $allUserScopeHelp = Test-Path (Join-Path $aboutHelpPathAllUsersScope "about_Splatting.help.txt") - if ((-not $userScopeHelp) -and (-not $aboutHelpPathAllUsersScope)) { + $userHelpPath = Join-Path $aboutHelpPathUserScope $helpFileName + $userScopeHelp = Test-Path $userHelpPath + if ($userScopeHelp) { + $expectedCompletionCount++ + } else { Update-Help -Force -ErrorAction SilentlyContinue -Scope 'CurrentUser' + if (Test-Path $userHelpPath) { + $expectedCompletionCount++ + } } - # If help content is present on both scopes, expect 2 or else expect 1 completion. - $expectedCompletions = if ($userScopeHelp -and $allUserScopeHelp) { 2 } else { 1 } + $allUserScopeHelpPath = Test-Path (Join-Path $aboutHelpPathAllUsersScope $helpFileName) + if ($allUserScopeHelpPath) { + $expectedCompletionCount++ + } - $res = TabExpansion2 -inputScript 'get-help about_spla' -cursorColumn 'get-help about_spla'.Length - $res.CompletionMatches | Should -HaveCount $expectedCompletions - $res.CompletionMatches[0].CompletionText | Should -BeExactly 'about_Splatting' + $res = TabExpansion2 -inputScript $inputScript -cursorColumn $inputScript.Length + $res.CompletionMatches | Should -HaveCount $expectedCompletionCount + $res.CompletionMatches[0].CompletionText | Should -BeExactly $helpName } + It 'Should complete about help topic regardless of culture' { try { ## Save original culture and temporarily set it to da-DK because there's no localized help for da-DK. $OriginalCulture = [cultureinfo]::CurrentCulture - [cultureinfo]::CurrentCulture="da-DK" + $defaultCulture = "en-US" + $culture = "da-DK" + [cultureinfo]::CurrentCulture = $culture + $helpName = "about_Splatting" + $helpFileName = "${helpName}.help.txt" + + $aboutHelpPathUserScope = Join-Path $userHelpRoot $culture + $aboutHelpPathAllUsersScope = Join-Path $PSHOME $culture + $expectedCompletionCount = 0 + + ## If help content does not exist, tab completion will not work. So update it first. + $userHelpPath = Join-Path $aboutHelpPathUserScope $helpFileName + $userScopeHelp = Test-Path $userHelpPath + if ($userScopeHelp) { + $expectedCompletionCount++ + } + else { Update-Help -Force -ErrorAction SilentlyContinue -Scope 'CurrentUser' + if (Test-Path $userHelpPath) { + $expectedCompletionCount++ + } + else { + $aboutHelpPathUserScope = Join-Path $userHelpRoot $defaultCulture + $aboutHelpPathAllUsersScope = Join-Path $PSHOME $defaultCulture + $userHelpDefaultPath = Join-Path $aboutHelpPathUserScope $helpFileName + $userDefaultScopeHelp = Test-Path $userHelpDefaultPath + + if ($userDefaultScopeHelp) { + $expectedCompletionCount++ + } + } + } + + $allUserScopeHelpPath = Test-Path (Join-Path $aboutHelpPathAllUsersScope $helpFileName) + if ($allUserScopeHelpPath) { + $expectedCompletionCount++ + } + else { + $aboutHelpPathAllUsersDefaultScope = Join-Path $PSHOME $defaultCulture + $allUsersDefaultScopeHelpPath = Test-Path (Join-Path $aboutHelpPathAllUsersDefaultScope $helpFileName) + + if ($allUsersDefaultScopeHelpPath) { + $expectedCompletionCount++ + } + } $res = TabExpansion2 -inputScript 'get-help about_spla' -cursorColumn 'get-help about_spla'.Length - $res.CompletionMatches | Should -HaveCount 1 - $res.CompletionMatches[0].CompletionText | Should -BeExactly 'about_Splatting' + $res.CompletionMatches | Should -HaveCount $expectedCompletionCount + $res.CompletionMatches[0].CompletionText | Should -BeExactly $helpName } finally { @@ -1683,7 +1850,7 @@ function MyFunction ($param1, $param2) Describe "Tab completion tests with remote Runspace" -Tags Feature,RequireAdminOnWindows { BeforeAll { - if ($IsWindows) { + if ($IsWindows -and -not (Test-IsWinWow64)) { $session = New-RemoteSession $powershell = [powershell]::Create() $powershell.Runspace = $session.Runspace diff --git a/test/powershell/Language/Scripting/NativeExecution/NativeCommandProcessor.Tests.ps1 b/test/powershell/Language/Scripting/NativeExecution/NativeCommandProcessor.Tests.ps1 index 8175c4b07ce..0a61b01c438 100644 --- a/test/powershell/Language/Scripting/NativeExecution/NativeCommandProcessor.Tests.ps1 +++ b/test/powershell/Language/Scripting/NativeExecution/NativeCommandProcessor.Tests.ps1 @@ -260,6 +260,14 @@ Describe "Run native command from a mounted FAT-format VHD" -tags @("Feature", " if (-not $IsWindows) { return; } + else { + $storageModule = Get-Module -Name 'Storage' -ListAvailable -ErrorAction SilentlyContinue + + if (-not $storageModule) { + Write-Verbose -Verbose "Storage module is not available." + return; + } + } $vhdx = Join-Path -Path $TestDrive -ChildPath ncp.vhdx @@ -283,11 +291,18 @@ Describe "Run native command from a mounted FAT-format VHD" -tags @("Feature", " diskpart.exe /s $create_vhdx Mount-DiskImage -ImagePath $vhdx > $null - Copy-Item "$env:WinDir\System32\whoami.exe" T:\whoami.exe + Copy-Item "$env:WinDir\System32\whoami.exe" "T:\whoami.exe" } AfterAll { if ($IsWindows) { + $storageModule = Get-Module -Name 'Storage' -ListAvailable -ErrorAction SilentlyContinue + + if (-not $storageModule) { + Write-Verbose -Verbose "Storage module is not available." + return; + } + Dismount-DiskImage -ImagePath $vhdx Remove-Item $vhdx, $create_vhdx -Force } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/RemoteGetModule.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/RemoteGetModule.Tests.ps1 index 2ad47aa2414..95e522ab9aa 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/RemoteGetModule.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/RemoteGetModule.Tests.ps1 @@ -4,7 +4,7 @@ Describe "Remote module tests" -Tags 'Feature','RequireAdminOnWindows' { BeforeAll { - if (!$IsWindows) + if (!$IsWindows -or (Test-IsWinWow64)) { $originalDefaultParameterValues = $PSDefaultParameterValues.Clone() $PSDefaultParameterValues["it:skip"] = $true diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/RemoteImportModule.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/RemoteImportModule.Tests.ps1 index e783a6f69e7..ba7f35f0485 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/RemoteImportModule.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/RemoteImportModule.Tests.ps1 @@ -5,7 +5,7 @@ Describe "Remote import-module tests" -Tags 'Feature','RequireAdminOnWindows' { BeforeAll { $originalDefaultParameterValues = $PSDefaultParameterValues.Clone() $modulePath = "$testdrive\Modules\TestImport" - if (!$IsWindows) { + if (!$IsWindows -or (Test-IsWinWow64)) { $PSDefaultParameterValues["it:skip"] = $true } else { $pssession = New-RemoteSession diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/CertificateProvider.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Security/CertificateProvider.Tests.ps1 index 88bccb20a37..c6c468e5f0b 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Security/CertificateProvider.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/CertificateProvider.Tests.ps1 @@ -82,8 +82,13 @@ Describe "Certificate Provider tests" -Tags "Feature" { BeforeAll{ if($IsWindows) { - Install-TestCertificates - Push-Location Cert:\ + if (-not (Install-TestCertificates) ) { + $SetupFailure = $true + } + else { + Push-Location Cert:\ + $SetupFailure = $false + } } else { @@ -94,28 +99,45 @@ Describe "Certificate Provider tests" -Tags "Feature" { } AfterAll { - if($IsWindows) + if($IsWindows -and -not $SetupFailure) { Remove-TestCertificates Pop-Location } else { - $global:PSDefaultParameterValues = $defaultParamValues + if ($defaultParamValues -ne $null) { + $global:PSDefaultParameterValues = $defaultParamValues + } } } Context "Get-Item tests" { It "Should be able to get certifate by path: " -TestCases $currentUserMyLocations { param([string] $path) + if ($SetupFailure) { + Set-ItResult -Inconclusive -Because "Test certificates are not installed" + } + + if ($SetupFailure) { + Set-ItResult -Inconclusive -Because "Test certificates are not installed" + } + $expectedThumbprint = (Get-GoodCertificateObject).Thumbprint $leafPath = Join-Path -Path $path -ChildPath $expectedThumbprint $cert = (Get-Item -LiteralPath $leafPath) - $cert | Should -Not -Be null + if ($SetupFailure) { + Set-ItResult -Inconclusive -Because "Test certificates are not installed" + } $cert.Thumbprint | Should -Be $expectedThumbprint } It "Should be able to get DnsNameList of certifate by path: " -TestCases $currentUserMyLocations { param([string] $path) + + if ($SetupFailure) { + Set-ItResult -Inconclusive -Because "Test certificates are not installed" + } + $expectedThumbprint = (Get-GoodCertificateObject).Thumbprint $expectedName = (Get-GoodCertificateObject).DnsNameList $expectedEncodedName = (Get-GoodCertificateObject).DnsNameList @@ -133,6 +155,11 @@ Describe "Certificate Provider tests" -Tags "Feature" { } it "Should be able to get EnhancedKeyUsageList of certifate by path: " -TestCases $currentUserMyLocations { param([string] $path) + + if ($SetupFailure) { + Set-ItResult -Inconclusive -Because "Test certificates are not installed" + } + $expectedThumbprint = (Get-GoodCertificateObject).Thumbprint $expectedOid = (Get-GoodCertificateObject).EnhancedKeyUsageList[0].ObjectId $leafPath = Join-Path -Path $path -ChildPath $expectedThumbprint @@ -144,6 +171,11 @@ Describe "Certificate Provider tests" -Tags "Feature" { $cert.EnhancedKeyUsageList[0].ObjectId | Should -Be $expectedOid } It "Should filter to codesign certificates" { + + if ($SetupFailure) { + Set-ItResult -Inconclusive -Because "Test certificates are not installed" + } + $allCerts = Get-Item cert:\CurrentUser\My\* $codeSignCerts = Get-Item cert:\CurrentUser\My\* -CodeSigningCert $codeSignCerts | Should -Not -Be null @@ -152,6 +184,11 @@ Describe "Certificate Provider tests" -Tags "Feature" { $nonCodeSignCertCount | Should -Not -Be 0 } It "Should be able to exclude by thumbprint" { + + if ($SetupFailure) { + Set-ItResult -Inconclusive -Because "Test certificates are not installed" + } + $allCerts = Get-Item cert:\CurrentUser\My\* $testThumbprint = (Get-GoodCertificateObject).Thumbprint $allCertsExceptOne = (Get-Item "cert:\currentuser\my\*" -Exclude $testThumbprint) @@ -166,6 +203,11 @@ Describe "Certificate Provider tests" -Tags "Feature" { $cert = Get-GoodServerCertificateObject } it "Should filter to codesign certificates" { + + if ($SetupFailure) { + Set-ItResult -Inconclusive -Because "Test certificates are not installed" + } + $allCerts = get-ChildItem cert:\CurrentUser\My $codeSignCerts = get-ChildItem cert:\CurrentUser\My -CodeSigningCert $codeSignCerts | Should -Not -Be null @@ -174,6 +216,11 @@ Describe "Certificate Provider tests" -Tags "Feature" { $nonCodeSignCertCount | Should -Not -Be 0 } it "Should filter to ExpiringInDays certificates" { + + if ($SetupFailure) { + Set-ItResult -Inconclusive -Because "Test certificates are not installed" + } + $thumbprint = $cert.Thumbprint $NotAfter = $cert.NotAfter $before = ($NotAfter.AddDays(-1) - (Get-Date)).Days @@ -186,6 +233,11 @@ Describe "Certificate Provider tests" -Tags "Feature" { $afterCerts.Thumbprint | Should -BeExactly $thumbprint } it "Should filter to DocumentEncryptionCert certificates" { + + if ($SetupFailure) { + Set-ItResult -Inconclusive -Because "Test certificates are not installed" + } + $thumbprint = $cert.Thumbprint $certs = Get-ChildItem cert:\CurrentUser\My\$thumbprint -DocumentEncryptionCert @@ -199,6 +251,10 @@ Describe "Certificate Provider tests" -Tags "Feature" { ) { param($name, $searchName, $count, $thumbprint) + if ($SetupFailure) { + Set-ItResult -Inconclusive -Because "Test certificates are not installed" + } + $certs = Get-ChildItem cert:\CurrentUser\My\$thumbprint -DNSName $searchName $certs.Count | Should -Be $count @@ -206,6 +262,11 @@ Describe "Certificate Provider tests" -Tags "Feature" { } it "Should filter to SSLServerAuthentication certificates" { + + if ($SetupFailure) { + Set-ItResult -Inconclusive -Because "Test certificates are not installed" + } + $thumbprint = $cert.Thumbprint $certs = Get-ChildItem cert:\CurrentUser\My\$thumbprint -SSLServerAuthentication @@ -221,6 +282,10 @@ Describe "Certificate Provider tests" -Tags "Feature" { ) { param($name, $ekuSearch, $count, $thumbprint) + if ($SetupFailure) { + Set-ItResult -Inconclusive -Because "Test certificates are not installed" + } + $certs = Get-ChildItem cert:\CurrentUser\My\$thumbprint -EKU $ekuSearch $certs.Count | Should -Be $count diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/CmsMessage.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Security/CmsMessage.Tests.ps1 index 67159e5c9e2..50cbdebab69 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Security/CmsMessage.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/CmsMessage.Tests.ps1 @@ -81,7 +81,12 @@ Describe "CmsMessage cmdlets thorough tests" -Tags "Feature" { BeforeAll{ if($IsWindows) { - Install-TestCertificates + if (-not (Install-TestCertificates) ) { + $SetupFailure = $true + } else { + Push-Location Cert:\ + $SetupFailure = $false + } } else { @@ -92,13 +97,16 @@ Describe "CmsMessage cmdlets thorough tests" -Tags "Feature" { } AfterAll { - if($IsWindows) + if($IsWindows -and -not $SetupFailure) { Remove-TestCertificates } else { - $global:PSdefaultParameterValues = $defaultParamValues + if ($defaultParamValues -ne $null) { + $global:PSDefaultParameterValues = $defaultParamValues + } + } } @@ -136,6 +144,7 @@ Describe "CmsMessage cmdlets thorough tests" -Tags "Feature" { } It "Verify wildcarded recipient resolution by path [Decryption]" { + if ($SetupFailure) { Set-ItResult -Inconclusive -Because "Test certificates are not installed"} $errors = $null $recipient = [System.Management.Automation.CmsMessageRecipient] ((Get-GoodCertificateLocation) + "*") $recipient.Resolve($ExecutionContext.SessionState, "Decryption", [ref] $errors) @@ -145,6 +154,7 @@ Describe "CmsMessage cmdlets thorough tests" -Tags "Feature" { } It "Verify wildcarded recipient resolution by path [Encryption]" { + if ($SetupFailure) { Set-ItResult -Inconclusive -Because "Test certificates are not installed"} $errors = $null $recipient = [System.Management.Automation.CmsMessageRecipient] ((Get-GoodCertificateLocation) + "*") $recipient.Resolve($ExecutionContext.SessionState, "Encryption", [ref] $errors) @@ -153,6 +163,7 @@ Describe "CmsMessage cmdlets thorough tests" -Tags "Feature" { } It "Verify resolution by directory" { + if ($SetupFailure) { Set-ItResult -Inconclusive -Because "Test certificates are not installed"} $protectedEventLoggingCertPath = Join-Path $TestDrive ProtectedEventLoggingDir $null = New-Item -ItemType Directory $protectedEventLoggingCertPath -Force Copy-Item (Get-GoodCertificateLocation) $protectedEventLoggingCertPath @@ -167,6 +178,7 @@ Describe "CmsMessage cmdlets thorough tests" -Tags "Feature" { } It "Verify resolution by thumbprint" { + if ($SetupFailure) { Set-ItResult -Inconclusive -Because "Test certificates are not installed"} $errors = $null $recipient = [System.Management.Automation.CmsMessageRecipient] (Get-GoodCertificateObject).Thumbprint $recipient.Resolve($ExecutionContext.SessionState, "Decryption", [ref] $errors) @@ -177,6 +189,7 @@ Describe "CmsMessage cmdlets thorough tests" -Tags "Feature" { } It "Verify resolution by subject name" { + if ($SetupFailure) { Set-ItResult -Inconclusive -Because "Test certificates are not installed"} $errors = $null $recipient = [System.Management.Automation.CmsMessageRecipient] (Get-GoodCertificateObject).Subject $recipient.Resolve($ExecutionContext.SessionState, "Decryption", [ref] $errors) @@ -186,6 +199,7 @@ Describe "CmsMessage cmdlets thorough tests" -Tags "Feature" { } It "Verify error when no cert found in encryption for encryption" { + if ($SetupFailure) { Set-ItResult -Inconclusive -Because "Test certificates are not installed"} $errors = $null $recipient = [System.Management.Automation.CmsMessageRecipient] "SomeCertificateThatDoesNotExist*" $recipient.Resolve($ExecutionContext.SessionState, "Encryption", [ref] $errors) @@ -195,6 +209,7 @@ Describe "CmsMessage cmdlets thorough tests" -Tags "Feature" { } It "Verify error when encrypting to non-wildcarded identifier for decryption" { + if ($SetupFailure) { Set-ItResult -Inconclusive -Because "Test certificates are not installed"} $errors = $null $recipient = [System.Management.Automation.CmsMessageRecipient] "SomeCertificateThatDoesNotExist" $recipient.Resolve($ExecutionContext.SessionState, "Decryption", [ref] $errors) @@ -204,6 +219,7 @@ Describe "CmsMessage cmdlets thorough tests" -Tags "Feature" { } It "Verify error when encrypting to wrong cert" { + if ($SetupFailure) { Set-ItResult -Inconclusive -Because "Test certificates are not installed"} $errors = $null $recipient = [System.Management.Automation.CmsMessageRecipient] (Get-BadCertificateObject).Thumbprint $recipient.Resolve($ExecutionContext.SessionState, "Encryption", [ref] $errors) @@ -213,6 +229,7 @@ Describe "CmsMessage cmdlets thorough tests" -Tags "Feature" { } It "Verify no error when encrypting to wildcarded identifier for decryption" { + if ($SetupFailure) { Set-ItResult -Inconclusive -Because "Test certificates are not installed"} $errors = $null $recipient = [System.Management.Automation.CmsMessageRecipient] "SomeCertificateThatDoesNotExist*" $recipient.Resolve($ExecutionContext.SessionState, "Decryption", [ref] $errors) @@ -222,11 +239,14 @@ Describe "CmsMessage cmdlets thorough tests" -Tags "Feature" { } It "Verify Protect-CmsMessage emits recipient errors" { + if ($SetupFailure) { Set-ItResult -Inconclusive -Because "Test certificates are not installed"} { "Hello World" | Protect-CmsMessage -To "SomeThumbprintThatDoesNotExist" -ErrorAction Stop } | Should -Throw -ErrorId "NoCertificateFound,Microsoft.PowerShell.Commands.ProtectCmsMessageCommand" } It "Verify CmsMessage cmdlets works with paths" { + if ($SetupFailure) { Set-ItResult -Inconclusive -Because "Test certificates are not installed"} + try { $randomNum = Get-Random -Minimum 1000 -Maximum 9999 $tempPath = Join-Path $TestDrive "$randomNum-Path-Test-File" @@ -251,6 +271,8 @@ Describe "CmsMessage cmdlets thorough tests" -Tags "Feature" { } It "Verify Unprotect-CmsMessage works with local store" { + if ($SetupFailure) { Set-ItResult -Inconclusive -Because "Test certificates are not installed"} + try { $randomNum = Get-Random -Minimum 1000 -Maximum 9999 $tempPath = Join-Path $TestDrive "$randomNum-Path-Test-File" @@ -265,27 +287,37 @@ Describe "CmsMessage cmdlets thorough tests" -Tags "Feature" { } It "Verify Unprotect-CmsMessage emits recipient errors" { + if ($SetupFailure) { Set-ItResult -Inconclusive -Because "Test certificates are not installed"} + { "" | Unprotect-CmsMessage -To "SomeThumbprintThatDoesNotExist" -IncludeContext -ErrorAction Stop } | Should -Throw -ErrorId "NoCertificateFound,Microsoft.PowerShell.Commands.UnprotectCmsMessageCommand" } It "Verify failure to extract Ascii armor generates an error [Unprotect-CmsMessage]" { + if ($SetupFailure) { Set-ItResult -Inconclusive -Because "Test certificates are not installed"} + { "Hello World" | Unprotect-CmsMessage -ErrorAction Stop } | Should -Throw -ErrorId "InputContainedNoEncryptedContentIncludeContext,Microsoft.PowerShell.Commands.UnprotectCmsMessageCommand" } It "Verify failure to extract Ascii armor generates an error [Get-CmsMessage]" { + if ($SetupFailure) { Set-ItResult -Inconclusive -Because "Test certificates are not installed"} + { "Hello World" | Get-CmsMessage -ErrorAction Stop } | Should -Throw -ErrorId "InputContainedNoEncryptedContent,Microsoft.PowerShell.Commands.GetCmsMessageCommand" } It "Verify 'Unprotect-CmsMessage -IncludeContext' with no encrypted input" { + if ($SetupFailure) { Set-ItResult -Inconclusive -Because "Test certificates are not installed"} + # Should have round-tripped content $result = "Hello World" | Unprotect-CmsMessage -IncludeContext $result | Should -Be "Hello World" } It "Verify Unprotect-CmsMessage lets you include context" { + if ($SetupFailure) { Set-ItResult -Inconclusive -Because "Test certificates are not installed"} + $protected = "Hello World" | Protect-CmsMessage -To (Get-GoodCertificateLocation) $adjustedProtected = "Pre content" + [System.Environment]::NewLine + $protected + [System.Environment]::NewLine + "Post content" @@ -299,6 +331,8 @@ Describe "CmsMessage cmdlets thorough tests" -Tags "Feature" { } It "Verify Unprotect-CmsMessage treats event logs as a first class citizen" { + if ($SetupFailure) { Set-ItResult -Inconclusive -Because "Test certificates are not installed"} + $protected = "Encrypted Message1","Encrypted Message2" | Protect-CmsMessage -To (Get-GoodCertificateLocation) $virtualEventLog = Get-WinEvent Microsoft-Windows-PowerShell/Operational -MaxEvents 1 $savedId = $virtualEventLog.Id @@ -327,6 +361,8 @@ Describe "CmsMessage cmdlets thorough tests" -Tags "Feature" { } It "Verify protect message using OutString" { + if ($SetupFailure) { Set-ItResult -Inconclusive -Because "Test certificates are not installed"} + $protected = Get-Process -Id $PID | Protect-CmsMessage -To (Get-GoodCertificateLocation) $decrypted = $protected | Unprotect-CmsMessage -To (Get-GoodCertificateLocation) # Should have had PID in output diff --git a/test/powershell/Modules/Microsoft.PowerShell.Security/certificateCommon.psm1 b/test/powershell/Modules/Microsoft.PowerShell.Security/certificateCommon.psm1 index 42e990b714e..5601767a120 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Security/certificateCommon.psm1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Security/certificateCommon.psm1 @@ -240,13 +240,19 @@ nMbw+XY4C8xdDnHfS6mF+Hol98dURB/MC/x3sZ3gSjKo function Install-TestCertificates { $script:certLocation = New-GoodCertificate - $script:certLocation | Should -Not -BeNullOrEmpty | Out-Null + if (-not $script:certLocation) { + return $false + } $script:certServerLocation = New-GoodServerCertificate - $script:certServerLocation | Should -Not -BeNullOrEmpty | Out-Null + if (-not $script:certServerLocation) { + return $false + } $script:badCertLocation = New-BadCertificate - $script:badCertLocation | Should -Not -BeNullOrEmpty | Out-Null + if (-not $script:badCertLocation) { + return $false + } if ($IsCoreCLR -and $IsWindows) { diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Table.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Table.Tests.ps1 index 3d4111e89a5..cdea1f1194e 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Table.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Format-Table.Tests.ps1 @@ -857,11 +857,17 @@ Describe 'Table color tests' { $PSStyle.OutputRendering = $originalRendering } - It 'Table header should use FormatAccent' { - ([pscustomobject]@{foo = 1} | Format-Table | Out-String).Trim() | Should -BeExactly @" -$($PSStyle.Formatting.FormatAccent)foo$($PSStyle.Reset) -$($PSStyle.Formatting.FormatAccent)---$($PSStyle.Reset) - 1 -"@ + It 'Table header should use TableHeader' { + $expected = @( + "" + "$($PSStyle.Formatting.TableHeader)foo$($PSStyle.Reset)" + "$($PSStyle.Formatting.TableHeader)---$($PSStyle.Reset)" + " 1" + "" + ) + + $actual = [pscustomobject]@{foo = 1} | Format-Table | Out-String -Stream + + $actual | Should -BeExactly $expected } } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 index 0b73e7be7aa..4b459fe67d9 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 @@ -5,7 +5,7 @@ $originalDefaultParameterValues = $PSDefaultParameterValues.Clone() $originalWarningPreference = $WarningPreference $WarningPreference = "SilentlyContinue" -$skipTest = ! ($IsWindows -and $IsCoreCLR -and (Test-IsElevated)) +$skipTest = ! ($IsWindows -and $IsCoreCLR -and (Test-IsElevated)) -or (Test-IsWinWow64) $PSDefaultParameterValues["it:skip"] = $skipTest try diff --git a/test/powershell/engine/ExperimentalFeature/Get-ExperimentalFeature.Tests.ps1 b/test/powershell/engine/ExperimentalFeature/Get-ExperimentalFeature.Tests.ps1 index af18672cf27..648850521f0 100644 --- a/test/powershell/engine/ExperimentalFeature/Get-ExperimentalFeature.Tests.ps1 +++ b/test/powershell/engine/ExperimentalFeature/Get-ExperimentalFeature.Tests.ps1 @@ -133,7 +133,7 @@ Describe "Get-ExperimentalFeature Tests" -tags "Feature","RequireAdminOnWindows" Describe "Default enablement of Experimental Features" -Tags CI { BeforeAll { - $isPreview = $PSVersionTable.GitCommitId -match "preview|daily" + $isPreview = (Test-IsPreview -Version $PSVersionTable.PSVersion) -and (-not (Test-IsReleaseCandidate -Version $PSVersionTable.PSVersion)) Function BeEnabled { [CmdletBinding()] diff --git a/test/powershell/engine/Remoting/RemoteSession.Disconnect.Tests.ps1 b/test/powershell/engine/Remoting/RemoteSession.Disconnect.Tests.ps1 index c98e3045e7e..a6a4f23e082 100644 --- a/test/powershell/engine/Remoting/RemoteSession.Disconnect.Tests.ps1 +++ b/test/powershell/engine/Remoting/RemoteSession.Disconnect.Tests.ps1 @@ -7,7 +7,7 @@ Describe "WinRM based remoting session abrupt disconnect" -Tags 'Feature','Requi BeforeAll { $originalDefaultParameterValues = $PSDefaultParameterValues.Clone() - if (! $IsWindows) + if (! $IsWindows -or (Test-IsWinWow64)) { $PSDefaultParameterValues["it:skip"] = $true return diff --git a/test/powershell/engine/Remoting/RunspacePool.Tests.ps1 b/test/powershell/engine/Remoting/RunspacePool.Tests.ps1 index 1266a6956e9..f4481c85eb0 100644 --- a/test/powershell/engine/Remoting/RunspacePool.Tests.ps1 +++ b/test/powershell/engine/Remoting/RunspacePool.Tests.ps1 @@ -8,7 +8,7 @@ Describe "Remote runspace pool should expose commands in endpoint configuration" BeforeAll { - if ($IsWindows -and (Test-CanWriteToPsHome)) + if ($IsWindows -and (Test-CanWriteToPsHome) -and -not (Test-IsWinWow64)) { $configName = "restrictedV" $configPath = Join-Path $TestDrive ($configName + ".pssc") @@ -19,10 +19,20 @@ Describe "Remote runspace pool should expose commands in endpoint configuration" $remoteRunspacePool = New-RemoteRunspacePool -ConfigurationName $configName } + elseif (Test-IsWinWow64) + { + $originalDefaultParameterValues = $PSDefaultParameterValues.Clone() + $PSDefaultParameterValues["it:skip"] = $true + } } AfterAll { + if (Test-IsWinWow64) { + $global:PSDefaultParameterValues = $originalDefaultParameterValues + return + } + if ($IsWindows -and (Test-CanWriteToPsHome)) { if ($remoteRunspacePool -ne $null) diff --git a/test/tools/Modules/HelpersCommon/HelpersCommon.psd1 b/test/tools/Modules/HelpersCommon/HelpersCommon.psd1 index 43d2ada88cc..c32f7e38b6e 100644 --- a/test/tools/Modules/HelpersCommon/HelpersCommon.psd1 +++ b/test/tools/Modules/HelpersCommon/HelpersCommon.psd1 @@ -28,9 +28,13 @@ FunctionsToExport = @( 'Set-TesthookResult' 'Start-NativeExecution' 'Test-IsElevated' + 'Test-IsPreview', + 'Test-IsReleaseCandidate' 'Test-IsRoot' 'Test-IsVstsLinux' 'Test-IsVstsWindows' + 'Test-IsWindowsArm64' + 'Test-IsWinWow64' 'Test-TesthookIsSet' 'Wait-FileToBePresent' 'Wait-UntilTrue' diff --git a/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 b/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 index 9e5510e0e82..317e42b1530 100644 --- a/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 +++ b/test/tools/Modules/HelpersCommon/HelpersCommon.psm1 @@ -402,3 +402,53 @@ function Get-WsManSupport { return $false } + +function Test-IsWindowsArm64 { + return $IsWindows -and [System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture -eq [System.Runtime.InteropServices.Architecture]::Arm64 +} + +function Test-IsWinWow64 { + return $IsWindows -and [System.Environment]::Is64BitOperatingSystem -and -not [System.Environment]::Is64BitProcess +} + +function Test-IsPreview +{ + param( + [parameter(Mandatory)] + [string] + $Version, + + [switch]$IsLTS + ) + + if ($IsLTS.IsPresent) { + ## If we are building a LTS package, then never consider it preview. + return $false + } + + return $Version -like '*-*' +} + +<# + .Synopsis + Tests if a version is a Release Candidate + .EXAMPLE + Test-IsReleaseCandidate -version '6.1.0-sometthing' # returns false + Test-IsReleaseCandidate -version '6.1.0-rc.1' # returns true + Test-IsReleaseCandidate -version '6.1.0' # returns false +#> +function Test-IsReleaseCandidate +{ + param( + [parameter(Mandatory)] + [string] + $Version + ) + + if ($Version -like '*-rc.*') + { + return $true + } + + return $false +} From 9fc8642474fb9fbfdb4bd7a9e3774070726138f3 Mon Sep 17 00:00:00 2001 From: "James Truher [MSFT]" Date: Mon, 27 Mar 2023 14:54:53 -0700 Subject: [PATCH 06/18] Improve package management acceptance tests by not going to the gallery (#19412) --- .../PackageManagement.Tests.ps1 | 72 ++++++++++-------- .../assets/PowerShell.TestPackage.3.2.1.nupkg | Bin 0 -> 3225 bytes 2 files changed, 41 insertions(+), 31 deletions(-) create mode 100644 test/powershell/Modules/PackageManagement/assets/PowerShell.TestPackage.3.2.1.nupkg diff --git a/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1 b/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1 index 3fea57db36f..bd4d0218f5d 100644 --- a/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1 +++ b/test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1 @@ -13,34 +13,36 @@ # # ------------------ PackageManagement Test ----------------------------------- -$gallery = "https://www.powershellgallery.com/api/v2" -$source = 'OneGetTestSource' - Describe "PackageManagement Acceptance Test" -Tags "Feature" { - BeforeAll{ - Register-PackageSource -Name Nugettest -provider NuGet -Location https://www.nuget.org/api/v2 -Force + BeforeAll { + # the package name for testing + $packageName = "PowerShell.TestPackage" + + # register the asset directory + $localSourceName = [Guid]::NewGuid().ToString("n") + $localSourceLocation = Join-Path $PSScriptRoot assets + Register-PackageSource -Name $localSourceName -provider NuGet -Location $localSourceLocation -Force -Trusted + + # register the gallery location + $galleryLocation = "https://www.powershellgallery.com/api/v2" + $gallerySourceName = [Guid]::newGuid().ToString("n") + Register-PackageSource -Name $gallerySourceName -Location $galleryLocation -ProviderName 'PowerShellGet' -Trusted -ErrorAction SilentlyContinue + + $SavedProgressPreference = $ProgressPreference + $ProgressPreference = "SilentlyContinue" + } - $packageSource = Get-PackageSource -Location $gallery -ErrorAction SilentlyContinue - if ($packageSource) { - $source = $packageSource.Name - Set-PackageSource -Name $source -Trusted - } else { - Register-PackageSource -Name $source -Location $gallery -ProviderName 'PowerShellGet' -Trusted -ErrorAction SilentlyContinue + AfterAll { + $ProgressPreference = $SavedProgressPreference + Unregister-PackageSource -Source $localSourceName -ErrorAction Ignore + Unregister-PackageSource -Name $gallerySourceName -ErrorAction Ignore + Uninstall-Module NanoServerPackage -ErrorAction Ignore -WarningAction SilentlyContinue } - $SavedProgressPreference = $ProgressPreference - $ProgressPreference = "SilentlyContinue" - } - AfterAll { - $ProgressPreference = $SavedProgressPreference - } It "get-packageprovider" { - $gpp = Get-PackageProvider - $gpp.Name | Should -Contain 'NuGet' - $gpp.Name | Should -Contain 'PowerShellGet' } @@ -50,32 +52,40 @@ Describe "PackageManagement Acceptance Test" -Tags "Feature" { } It "install-packageprovider, Expect succeed" { - $ipp = (Install-PackageProvider -Name NanoServerPackage -Force -Source $source -Scope CurrentUser).name + Set-ItResult -Pending -Because "local test package provider not installable" + $ippArgs = @{ + Name = "NanoServerPackage" + Force = $true + Source = $galleryLocation + Scope = "CurrentUser" + WarningAction = "SilentlyContinue" + } + $ipp = (Install-PackageProvider @ippArgs).name $ipp | Should -Contain "NanoServerPackage" } It "Find-package" { - $f = Find-Package -ProviderName NuGet -Name jquery -Source Nugettest - $f.Name | Should -Contain "jquery" + $f = Find-Package -ProviderName NuGet -Name $packageName -Source $localSourceName + $f.Name | Should -Contain "$packageName" } It "Install-package" { - $i = Install-Package -ProviderName NuGet -Name jquery -Force -Source Nugettest -Scope CurrentUser - $i.Name | Should -Contain "jquery" + $i = Install-Package -ProviderName NuGet -Name $packageName -Force -Source $localSourceName -Scope CurrentUser + $i.Name | Should -Contain "$packageName" } It "Get-package" { - $g = Get-Package -ProviderName NuGet -Name jquery - $g.Name | Should -Contain "jquery" + $g = Get-Package -ProviderName NuGet -Name $packageName + $g.Name | Should -Contain "$packageName" } It "save-package" { - $s = Save-Package -ProviderName NuGet -Name jquery -Path $TestDrive -Force -Source Nugettest - $s.Name | Should -Contain "jquery" + $s = Save-Package -ProviderName NuGet -Name $packageName -Path $TestDrive -Force -Source $localSourceName + $s.Name | Should -Contain "$packageName" } It "uninstall-package" { - $u = Uninstall-Package -ProviderName NuGet -Name jquery - $u.Name | Should -Contain "jquery" + $u = Uninstall-Package -ProviderName NuGet -Name $packageName + $u.Name | Should -Contain "$packageName" } } diff --git a/test/powershell/Modules/PackageManagement/assets/PowerShell.TestPackage.3.2.1.nupkg b/test/powershell/Modules/PackageManagement/assets/PowerShell.TestPackage.3.2.1.nupkg new file mode 100644 index 0000000000000000000000000000000000000000..bc3a6d9b094ff479b0acef2b1e54415e559c339d GIT binary patch literal 3225 zcmb_ecU03$8Vy}Rib(Y-hy|1qLMMWvB1ixUH7cTzgh&ku5K10B5I{sB5E1DmAWe9R zG=b1jKp@ha5D^fh3ZW=%;}OPy%i-QxuE{WeVYXO~9FDJpd^KrOxNN-$ey%!- zH3Sp7h?IU#-7+t?w=i&xG zlPCCL*gB$my5C|Hadqhsqa@*~u25Qp@S*PLDoD&Gmf(MT)2#f8r@9?E)VVO?EK5Z{8>^YVoiy zf-Gr%^FcdgD4Ihh(d#8?re&Q~Ys^7VA_RRVOT*%n$ROEiC2?5uHY=LChVI*888>G?N zV*DHQ%R99iO-q+5UQ{?waxMEUZ?938H)}T&V}?s5E#e}rLF(#}1Lr78-yN)*X26S5T^VRtg0&M73oM$Uf zEP`j7v|gIb2yspT@I+$L_zSy#eqtg)TR6TyxP(3NiFNktk)xGJsjkAbWpN=moBl0F z=R(OoWWgKs;DHz1@016Mw|81An%?n-t&zui4DqLHi8c#xXV)vAT8?~@A5rMB)h@c% zM|$^`mPdOPr|^YPwR}8_|EA{ms1OHmuA=tF=_bMLnFkD3XZQj}@eZVlC;REa8Lt1B3Mzb3nOLKSSQ$}Z1&UcK=^0)cTY5GNvBd!EJ=%Llf z;bE&9XX>QBdD1Ooq@B^vTy4_4^eh4$pb33Da;8>$KEXvjhe;9yGS-MW^v%mws2Elh*_8zF+K*6IQi=TC3aA(=b(CyRA+R@7HCm0onI-XfBOj zA_}E5kh*Yu<8w=e+p;`k1F)&~x*)%C-81?$dAFPba3Qa5<_tTGXcS;Kmw@I_k}I(c zwd&8edeXUNtuU%Cd}BBGMjxx~t12mMtTTIYMSl0Kq`AsKJMq8|YVUHwt*|9;Yab*u z?9N7i&2?uPo2Yptrvs}ypSdwZoi*6|zB`BE>B|Bo7|J$VznEPTK{$MgsPI#FqptMk z3q9ED+Ptp;Gi0P~y!rwe1eYUL3W9G~uZ|gA47K&$P4&HBn((oTS{(`P0P1UDb8Xh} zXQT6)zQjg#J9A~j&Iv4{`jUMVS-uNapv%Hy%P? zH=BIipFjWly}5d!L9DrwXY@njb<;r@iMz$-Yx`%FYK&whsdnT2Z`p%gH99~9<#T{` z4uj))o#N3MEN>{aCKQzMIR@#A^tjE^APot-g&OTXzrWWKh1j!uBvX?4|&ZcCrs=K zx(lw>#kTG^3teLn&}foJ4>Ck`Rp8AP=*P%8+R3V(aYdiUcKsRa@WHde={)Bs^9mMO z?f?sbBG2!o5K7=&eE$A1={qSbGkmi$bc@V_cQ2x%R1IwO)AdfXx!;-cK5WGJri9al zb(5M_a$<-F++A&24+)qNbHmq_pRO)gyx8RtlQ^lm@vuHf40+(xsWq<#+de@9Tdu7I zvGy6frEHT?&1mS$H}C4Z$y$14R=zyV(h6-!Lio*--8PhpEbU~?)QB#hxU{P&HQHs$ z3!MI+9FijT;)*Dd3pPvU?r)CmDg|3LJwjnsR=YD|FfkRoeMcSiah7Qq5tuEa|8S77 z@I_y!Z`VHFym7y`{hEYY?Eah?ZQ^J3x;#;C*2{c;JDBRllsCX_U5pzJ<%YAh#A8vO zcYwZV*A&tPwgjLlx#&$l!vzy66L9gM&aQ0a2#9_iSa-wU_CHc zln2gg} zN8fR4u}8D)#x>1cino*z{);1}&u=+F{9+d;cp^0)V$gNByU)~u6O#Oc*V>chBOS#A zK#hhd?^~vyyuHQ8rs6Gca>+T!Ve{(aVfH)bQSw8lU`DM4BTmjA9zhx|=^o^~@W8Q| zKzcwo+%L(vra$w(kkqfri=Ir=;BShotnk&a~CI{tMs;1uFx-ndI)QD&Gpj5t)(Z}FyuW#+@^Z`Fwl2CmIITg-kMG!Ty z8Y&0b1`uPn(<|xmN?lhj_E%$-8tB!o$;Qq~I3RTZiY@F}yYoiBc7 zZ-sd!2*t`Suo#P6OGf)w8B|8c^F)dcGS)Ls%zFdlv>-F8#>43=koLe5^Sy)rx?~ns zA-4Z)c$qi-&yN!FBmA5FH8uKq;ja$w&t(7rCB%T4HUHJ`{RH(luIDePAZGIYZx8en w9y4`+E#JTJI1l`7G5-qiYwrIAz|Exb|6U2EMjV_!w%}kkGLyVz?jOB>0Jg-hYybcN literal 0 HcmV?d00001 From 8450602d59d78466411c426162510a00a49ffc95 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Mon, 27 Mar 2023 17:36:41 -0700 Subject: [PATCH 07/18] Skip VT100 tests on Windows Server 2012R2 as console does not support it (#19413) --- .../Scripting/SuppressAnsiEscapeSequence.Tests.ps1 | 7 +++++++ .../Microsoft.PowerShell.Utility/Get-Error.Tests.ps1 | 5 +++++ .../engine/Formatting/OutputRendering.Tests.ps1 | 11 ++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/test/powershell/Language/Scripting/SuppressAnsiEscapeSequence.Tests.ps1 b/test/powershell/Language/Scripting/SuppressAnsiEscapeSequence.Tests.ps1 index 30a82309a70..0530aea93ee 100644 --- a/test/powershell/Language/Scripting/SuppressAnsiEscapeSequence.Tests.ps1 +++ b/test/powershell/Language/Scripting/SuppressAnsiEscapeSequence.Tests.ps1 @@ -3,12 +3,19 @@ Describe '$env:__SuppressAnsiEscapeSequences tests' -Tag CI { BeforeAll { + $originalDefaultParameterValues = $PSDefaultParameterValues.Clone() + + if (-not $host.ui.SupportsVirtualTerminal) { + $global:PSDefaultParameterValues["it:skip"] = $true + } + $originalSuppressPref = $env:__SuppressAnsiEscapeSequences $originalRendering = $PSStyle.OutputRendering $PSStyle.OutputRendering = 'Ansi' } AfterAll { + $global:PSDefaultParameterValues = $originalDefaultParameterValues $env:__SuppressAnsiEscapeSequences = $originalSuppressPref $PSStyle.OutputRendering = $originalRendering } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Error.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Error.Tests.ps1 index 0627de64b3a..b9d813d6d8c 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Error.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-Error.Tests.ps1 @@ -127,6 +127,11 @@ Describe 'Get-Error tests' -Tag CI { } It 'Get-Error uses Error color for Message and PositionMessage members' { + + if (-not $host.ui.SupportsVirtualTerminal) { + Set-ItResult -Skipped -Because 'Windows Server 2012 R2 does not support VT100 escape sequences' + } + $suppressVT = $false if (Test-Path env:/__SuppressAnsiEscapeSequences) { $suppressVT = $true diff --git a/test/powershell/engine/Formatting/OutputRendering.Tests.ps1 b/test/powershell/engine/Formatting/OutputRendering.Tests.ps1 index 7b67f71233c..fe01490944b 100644 --- a/test/powershell/engine/Formatting/OutputRendering.Tests.ps1 +++ b/test/powershell/engine/Formatting/OutputRendering.Tests.ps1 @@ -1,7 +1,16 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. -Describe 'OutputRendering tests' { +Describe 'OutputRendering tests' -Tag 'CI' { + BeforeAll { + $originalDefaultParameterValues = $PSDefaultParameterValues.Clone() + # Console host does not support VT100 escape sequences on Windows 2012R2 or earlier + + if (-not $host.ui.SupportsVirtualTerminal) { + $global:PSDefaultParameterValues["it:skip"] = $true + } + } + BeforeEach { if ($null -ne $PSStyle) { $oldOutputRendering = $PSStyle.OutputRendering From 1c7ec2f582ef8e0130138b2c11cd17a5e285c0fc Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Mon, 13 Mar 2023 19:22:30 -0700 Subject: [PATCH 08/18] Restructure the package build to simplify signing and packaging stages (#19321) --- .../releaseBuild/azureDevOps/releaseBuild.yml | 299 +++++++++++----- .../templates/compliance/compliance.yml | 2 +- .../azureDevOps/templates/json.yml | 2 +- .../azureDevOps/templates/linux-packaging.yml | 2 - .../templates/mac-file-signing.yml | 1 - .../templates/mac-package-build.yml | 1 - .../azureDevOps/templates/nuget.yml | 2 +- .../azureDevOps/templates/sign-build-file.yml | 324 ++++++++++++++++++ .../templates/windows-hosted-build.yml | 2 +- .../templates/windows-package-signing.yml | 2 +- .../templates/windows-packaging.yml | 3 +- 11 files changed, 534 insertions(+), 106 deletions(-) create mode 100644 tools/releaseBuild/azureDevOps/templates/sign-build-file.yml diff --git a/tools/releaseBuild/azureDevOps/releaseBuild.yml b/tools/releaseBuild/azureDevOps/releaseBuild.yml index e21b4fe0c4e..98d7279883f 100644 --- a/tools/releaseBuild/azureDevOps/releaseBuild.yml +++ b/tools/releaseBuild/azureDevOps/releaseBuild.yml @@ -49,6 +49,7 @@ variables: value: spdx:2.2 - name: BUILDSECMON_OPT_IN value: true + - group: PoolNames stages: - stage: prep @@ -66,30 +67,6 @@ stages: parameters: buildArchitecture: arm64 - - template: templates/mac-file-signing.yml - parameters: - buildArchitecture: x64 - - - template: templates/mac-file-signing.yml - parameters: - buildArchitecture: arm64 - - - template: templates/mac-package-build.yml - parameters: - buildArchitecture: x64 - - - template: templates/mac-package-build.yml - parameters: - buildArchitecture: arm64 - - - template: templates/mac-package-signing.yml - parameters: - buildArchitecture: x64 - - - template: templates/mac-package-signing.yml - parameters: - buildArchitecture: arm64 - - stage: linux dependsOn: ['prep'] jobs: @@ -111,29 +88,6 @@ stages: parameters: buildName: alpine - - template: templates/linux-authenticode-sign.yml - - - template: templates/linux-packaging.yml - parameters: - buildName: deb - parentJob: sign_linux_builds - - - template: templates/linux-packaging.yml - parameters: - buildName: rpm - uploadDisplayName: Upload and Sign - parentJob: sign_linux_builds - - - template: templates/linux-packaging.yml - parameters: - buildName: alpine - parentJob: sign_linux_builds - - - template: templates/linux-packaging.yml - parameters: - buildName: fxdependent - parentJob: sign_linux_builds - - stage: windows dependsOn: ['prep'] jobs: @@ -166,66 +120,221 @@ stages: parameters: Architecture: fxdependentWinDesktop - - template: templates/windows-packaging.yml - parameters: - Architecture: x64 - parentJob: build_windows_x64_release - - - template: templates/windows-packaging.yml - parameters: - Architecture: x64 - BuildConfiguration: minSize - parentJob: build_windows_x64_minSize - - - template: templates/windows-packaging.yml - parameters: - Architecture: x86 - parentJob: build_windows_x86_release - - - template: templates/windows-packaging.yml - parameters: - Architecture: arm - parentJob: build_windows_arm_release - - - template: templates/windows-packaging.yml - parameters: - Architecture: arm64 - parentJob: build_windows_arm64_release - - - template: templates/windows-packaging.yml - parameters: - Architecture: fxdependent - parentJob: build_windows_fxdependent_release + - stage: SignFiles + displayName: Sign files + dependsOn: ['windows', 'linux', 'macos'] + jobs: + - template: templates/mac-file-signing.yml + parameters: + buildArchitecture: x64 + + - template: templates/mac-file-signing.yml + parameters: + buildArchitecture: arm64 + + - job: SignFilesWinLinux + pool: + name: $(windowsPool) + demands: + - ImageOverride -equals PSMMS2019-Secure + displayName: Sign files + + variables: + - group: ESRP + - name: runCodesignValidationInjection + value: false + - name: NugetSecurityAnalysisWarningLevel + value: none + - name: repoFolder + value: PowerShell + - name: repoRoot + value: $(Agent.BuildDirectory)\$(repoFolder) + - name: complianceRepoFolder + value: compliance + + strategy: + matrix: + linux-x64: + runtime: linux-x64 + unsignedBuildArtifactContainer: pwshLinuxBuild.tar.gz + unsignedBuildArtifactName: pwshLinuxBuild.tar.gz + signedBuildArtifactName: pwshLinuxBuild.tar.gz + signedArtifactContainer: authenticode-signed + linux-x64-Alpine: + runtime: linux-x64-Alpine + unsignedBuildArtifactContainer: pwshLinuxBuildAlpine.tar.gz + unsignedBuildArtifactName: pwshLinuxBuild.tar.gz + signedBuildArtifactName: pwshLinuxBuildAlpine.tar.gz + signedArtifactContainer: authenticode-signed + linux-arm32: + runtime: linux-arm32 + unsignedBuildArtifactContainer: pwshLinuxBuildArm32.tar.gz + unsignedBuildArtifactName: pwshLinuxBuildArm32.tar.gz + signedBuildArtifactName: pwshLinuxBuildArm32.tar.gz + signedArtifactContainer: authenticode-signed + linux-arm64: + runtime: linux-arm64 + unsignedBuildArtifactContainer: pwshLinuxBuildArm64.tar.gz + unsignedBuildArtifactName: pwshLinuxBuildArm64.tar.gz + signedBuildArtifactName: pwshLinuxBuildArm64.tar.gz + signedArtifactContainer: authenticode-signed + linux-fxd: + runtime: linux-fxd + unsignedBuildArtifactContainer: pwshLinuxBuildFxdependent.tar.gz + unsignedBuildArtifactName: pwshLinuxBuild.tar.gz + signedBuildArtifactName: pwshLinuxBuildFxdependent.tar.gz + signedArtifactContainer: authenticode-signed + linux-mariner: + runtime: linux-mariner + unsignedBuildArtifactContainer: pwshMarinerBuildAmd64.tar.gz + unsignedBuildArtifactName: pwshMarinerBuildAmd64.tar.gz + signedBuildArtifactName: pwshMarinerBuildAmd64.tar.gz + signedArtifactContainer: authenticode-signed + linux-minsize: + runtime: linux-minsize + unsignedBuildArtifactContainer: pwshLinuxBuildMinSize.tar.gz + unsignedBuildArtifactName: pwshLinuxBuildMinSize.tar.gz + signedBuildArtifactName: pwshLinuxBuildMinSize.tar.gz + signedArtifactContainer: authenticode-signed + win-x64: + runtime: win-x64 + unsignedBuildArtifactContainer: results + unsignedBuildArtifactName: '**/*-symbols-win-x64.zip' + signedBuildArtifactName: '-symbols-win-x64-signed.zip' + signedArtifactContainer: results + win-x86: + runtime: win-x86 + unsignedBuildArtifactContainer: results + unsignedBuildArtifactName: '**/*-symbols-win-x86.zip' + signedBuildArtifactName: '-symbols-win-x86-signed.zip' + signedArtifactContainer: results + win-arm32: + runtime: win-arm32 + unsignedBuildArtifactContainer: results + unsignedBuildArtifactName: '**/*-symbols-win-arm32.zip' + signedBuildArtifactName: '-symbols-win-arm32-signed.zip' + signedArtifactContainer: results + win-arm64: + runtime: win-arm64 + unsignedBuildArtifactContainer: results + unsignedBuildArtifactName: '**/*-symbols-win-arm64.zip' + signedBuildArtifactName: '-symbols-win-arm64-signed.zip' + signedArtifactContainer: results + win-x64-gc: + runtime: win-x64-gc + unsignedBuildArtifactContainer: results + unsignedBuildArtifactName: '**/*-symbols-win-x64-gc.zip' + signedBuildArtifactName: '-symbols-win-x64-gc-signed.zip' + signedArtifactContainer: results + win-fxdependent: + runtime: win-fxdependent + unsignedBuildArtifactContainer: results + unsignedBuildArtifactName: '**/*-symbols-win-fxdependent.zip' + signedBuildArtifactName: '-symbols-win-fxdependent-signed.zip' + signedArtifactContainer: results + win-fxdependentWinDesktop: + runtime: win-fxdependentWinDesktop + unsignedBuildArtifactContainer: results + unsignedBuildArtifactName: '**/*-symbols-win-fxdependentWinDesktop.zip' + signedBuildArtifactName: '-symbols-win-fxdependentWinDesktop-signed.zip' + signedArtifactContainer: results + steps: + - template: templates/sign-build-file.yml + + - stage: mac_packaging + displayName: macOS packaging + dependsOn: ['SignFiles'] + jobs: + - template: templates/mac-package-build.yml + parameters: + buildArchitecture: x64 - - template: templates/windows-packaging.yml - parameters: - Architecture: fxdependentWinDesktop - parentJob: build_windows_fxdependentWinDesktop_release + - template: templates/mac-package-build.yml + parameters: + buildArchitecture: arm64 - - template: templates/windows-package-signing.yml - parameters: - parentJobs: - - sign_windows_x64_release - - sign_windows_x64_minSize - - sign_windows_x86_release - - sign_windows_arm_release - - sign_windows_arm64_release - - sign_windows_fxdependent_release - - sign_windows_fxdependentWinDesktop_release + - stage: linux_packaging + displayName: Linux Packaging + dependsOn: ['SignFiles'] + jobs: + - template: templates/linux-packaging.yml + parameters: + buildName: deb + + - template: templates/linux-packaging.yml + parameters: + buildName: rpm + uploadDisplayName: Upload and Sign + + - template: templates/linux-packaging.yml + parameters: + buildName: alpine + + - template: templates/linux-packaging.yml + parameters: + buildName: fxdependent + + - stage: win_packaging + displayName: Windows Packaging + dependsOn: ['SignFiles'] + jobs: + - template: templates/windows-packaging.yml + parameters: + Architecture: x64 + parentJob: build_windows_x64_release + + - template: templates/windows-packaging.yml + parameters: + Architecture: x64 + BuildConfiguration: minSize + parentJob: build_windows_x64_minSize + + - template: templates/windows-packaging.yml + parameters: + Architecture: x86 + parentJob: build_windows_x86_release + + - template: templates/windows-packaging.yml + parameters: + Architecture: arm + parentJob: build_windows_arm_release + + - template: templates/windows-packaging.yml + parameters: + Architecture: arm64 + parentJob: build_windows_arm64_release + + - template: templates/windows-packaging.yml + parameters: + Architecture: fxdependent + parentJob: build_windows_fxdependent_release + + - template: templates/windows-packaging.yml + parameters: + Architecture: fxdependentWinDesktop + parentJob: build_windows_fxdependentWinDesktop_release + + - stage: package_signing + displayName: Package Signing + dependsOn: ['mac_packaging', 'linux_packaging', 'win_packaging'] + jobs: + - template: templates/windows-package-signing.yml + # This is done late so that we dont use resources before the big signing and packaging tasks. - stage: compliance - dependsOn: ['windows'] + dependsOn: ['package_signing'] jobs: - template: templates/compliance.yml - stage: nuget_and_json - dependsOn: ['windows','linux','macOS'] + displayName: NuGet Packaging and Build Json + dependsOn: [package_signing] jobs: - template: templates/nuget.yml - - template: templates/json.yml - stage: test_and_release_artifacts + displayName: Test and Release Artifacts dependsOn: ['prep'] jobs: - template: templates/testartifacts.yml @@ -233,7 +342,7 @@ stages: - job: release_json displayName: Create and Upload release.json pool: - name: PowerShell1ES + name: $(windowsPool) demands: - ImageOverride -equals PSMMS2019-Secure steps: diff --git a/tools/releaseBuild/azureDevOps/templates/compliance/compliance.yml b/tools/releaseBuild/azureDevOps/templates/compliance/compliance.yml index eb0400bc3fe..e569b064893 100644 --- a/tools/releaseBuild/azureDevOps/templates/compliance/compliance.yml +++ b/tools/releaseBuild/azureDevOps/templates/compliance/compliance.yml @@ -17,7 +17,7 @@ jobs: dependsOn: ${{ parameters.parentJobs }} pool: - name: PowerShell1ES + name: $(windowsPool) demands: - ImageOverride -equals PSMMS2019-Secure diff --git a/tools/releaseBuild/azureDevOps/templates/json.yml b/tools/releaseBuild/azureDevOps/templates/json.yml index 1d6c10b8f3e..48a50e0bf14 100644 --- a/tools/releaseBuild/azureDevOps/templates/json.yml +++ b/tools/releaseBuild/azureDevOps/templates/json.yml @@ -13,7 +13,7 @@ jobs: ${{ parameters.parentJobs }} condition: succeeded() pool: - name: PowerShell1ES + name: $(windowsPool) demands: - ImageOverride -equals PSMMS2019-Secure diff --git a/tools/releaseBuild/azureDevOps/templates/linux-packaging.yml b/tools/releaseBuild/azureDevOps/templates/linux-packaging.yml index 2935849d9d0..2255e76c4e5 100644 --- a/tools/releaseBuild/azureDevOps/templates/linux-packaging.yml +++ b/tools/releaseBuild/azureDevOps/templates/linux-packaging.yml @@ -1,7 +1,6 @@ parameters: buildName: '' uploadDisplayName: 'Upload' - parentJob: '' jobs: - job: pkg_${{ parameters.buildName }} @@ -11,7 +10,6 @@ jobs: name: PowerShell1ES demands: - ImageOverride -equals PSMMSUbuntu20.04-Secure - dependsOn: sign_linux_builds variables: - name: runCodesignValidationInjection value: false diff --git a/tools/releaseBuild/azureDevOps/templates/mac-file-signing.yml b/tools/releaseBuild/azureDevOps/templates/mac-file-signing.yml index 5af4295994e..8159c2bc7d9 100644 --- a/tools/releaseBuild/azureDevOps/templates/mac-file-signing.yml +++ b/tools/releaseBuild/azureDevOps/templates/mac-file-signing.yml @@ -4,7 +4,6 @@ parameters: jobs: - job: MacFileSigningJob_${{ parameters.buildArchitecture }} displayName: macOS File signing ${{ parameters.buildArchitecture }} - dependsOn: build_macOS_${{ parameters.buildArchitecture }} condition: succeeded() pool: name: PowerShell1ES diff --git a/tools/releaseBuild/azureDevOps/templates/mac-package-build.yml b/tools/releaseBuild/azureDevOps/templates/mac-package-build.yml index e61ea99004f..0f3b607111d 100644 --- a/tools/releaseBuild/azureDevOps/templates/mac-package-build.yml +++ b/tools/releaseBuild/azureDevOps/templates/mac-package-build.yml @@ -5,7 +5,6 @@ parameters: jobs: - job: package_macOS_${{ parameters.buildArchitecture }} displayName: Package macOS ${{ parameters.buildArchitecture }} - dependsOn: MacFileSigningJob_${{ parameters.buildArchitecture }} condition: succeeded() pool: vmImage: macos-latest diff --git a/tools/releaseBuild/azureDevOps/templates/nuget.yml b/tools/releaseBuild/azureDevOps/templates/nuget.yml index 1d3fe2b9472..810b0dc6dff 100644 --- a/tools/releaseBuild/azureDevOps/templates/nuget.yml +++ b/tools/releaseBuild/azureDevOps/templates/nuget.yml @@ -8,7 +8,7 @@ jobs: displayName: Build NuGet packages condition: succeeded() pool: - name: PowerShell1ES + name: $(windowsPool) demands: - ImageOverride -equals PSMMS2019-Secure diff --git a/tools/releaseBuild/azureDevOps/templates/sign-build-file.yml b/tools/releaseBuild/azureDevOps/templates/sign-build-file.yml new file mode 100644 index 00000000000..cfa172796d8 --- /dev/null +++ b/tools/releaseBuild/azureDevOps/templates/sign-build-file.yml @@ -0,0 +1,324 @@ +steps: +- pwsh: | + $platform = '$(runtime)' -match '^linux' ? 'linux' : 'windows' + $vstsCommandString = "vso[task.setvariable variable=ArtifactPlatform]$platform" + Write-Host ("sending " + $vstsCommandString) + Write-Host "##$vstsCommandString" + displayName: Set artifact platform + +- task: DownloadPipelineArtifact@2 + inputs: + artifactName: '$(unsignedBuildArtifactContainer)' + itemPattern: '$(unsignedBuildArtifactName)' + +- pwsh: | + Get-ChildItem "$(Pipeline.Workspace)\*" -Recurse + displayName: 'Capture Downloaded Artifacts' + # Diagnostics is not critical it passes every time it runs + continueOnError: true + +- checkout: self + clean: true + path: $(repoFolder) + +- template: SetVersionVariables.yml + parameters: + ReleaseTagVar: $(ReleaseTagVar) + +- template: cloneToOfficialPath.yml + +- pwsh: | + $zipFileFilter = '$(unsignedBuildArtifactName)' + $zipFileFilter = $zipFileFilter.Replace('**/', '') + + Write-Verbose -Verbose -Message "zipFileFilter = $zipFileFilter" + + Write-Verbose -Verbose -Message "Looking for $(Pipeline.Workspace)\$(unsignedBuildArtifactName)" + + $zipFilePath = Get-ChildItem -Path '$(Pipeline.Workspace)\$(unsignedBuildArtifactName)' -recurse + + if (-not (Test-Path $zipFilePath)) + { + throw "zip file not found: $zipfilePath" + } + + if ($zipFilePath.Count -ne 1) { + Write-Verbose "zip filename" -verbose + $zipFilePath | Out-String | Write-Verbose -Verbose + throw 'multiple zip files found when 1 was expected' + } + + $expandedFolderName = [System.io.path]::GetFileNameWithoutExtension($zipfilePath) + $expandedFolderPath = Join-Path '$(Pipeline.Workspace)' 'expanded' $expandedFolderName + + Write-Verbose -Verbose -Message "Expaning $zipFilePath to $expandedFolderPath" + + New-Item -Path $expandedFolderPath -ItemType Directory + Expand-Archive -Path $zipFilePath -DestinationPath $expandedFolderPath + + if (-not (Test-Path $expandedFolderPath\pwsh.exe) ) { + throw 'zip did not expand as expected' + } + else { + $vstsCommandString = "vso[task.setvariable variable=BinPath]$expandedFolderPath" + Write-Host ("sending " + $vstsCommandString) + Write-Host "##$vstsCommandString" + } + + displayName: Expand zip packages + condition: eq(variables['ArtifactPlatform'], 'windows') + +- pwsh: | + $tarPackageName = '$(unsignedBuildArtifactName)' + + Write-Verbose -Verbose -Message "tarPackageName = $tarPackageName" + + $tarPackagePath = Join-Path '$(Pipeline.Workspace)' $tarPackageName + + Write-Verbose -Verbose -Message "Looking for: $tarPackagePath" + + $expandedPathFolderName = $tarPackageName -replace '.tar.gz', '' + $expandedFolderPath = Join-Path '$(Pipeline.Workspace)' 'expanded' $expandedPathFolderName + + if (-not (Test-Path $tarPackagePath)) + { + throw "tar file not found: $tarPackagePath" + } + + Write-Verbose -Verbose -Message "Expanding $tarPackagePath to $expandedFolderPath" + + New-Item -Path $expandedFolderPath -ItemType Directory + tar -xf $tarPackagePath -C $expandedFolderPath + + if (-not (Test-Path $expandedFolderPath/pwsh) ) { + throw 'tar.gz did not expand as expected' + } + else { + $vstsCommandString = "vso[task.setvariable variable=BinPath]$expandedFolderPath" + Write-Host ("sending " + $vstsCommandString) + Write-Host "##$vstsCommandString" + } + + Write-Verbose -Verbose "File permisions after expanding" + Get-ChildItem -Path "$expandedFolderPath/pwsh" | Select-Object -Property 'unixmode', 'size', 'name' + displayName: Expand tar.gz packages + condition: eq(variables['ArtifactPlatform'], 'linux') + +- template: insert-nuget-config-azfeed.yml + parameters: + repoRoot: $(PowerShellRoot) + +- pwsh: | + Set-Location $env:POWERSHELLROOT + import-module "$env:POWERSHELLROOT/build.psm1" + Sync-PSTags -AddRemoteIfMissing + displayName: SyncTags + condition: and(succeeded(), ne(variables['SkipBuild'], 'true')) + +- checkout: ComplianceRepo + clean: true + path: $(complianceRepoFolder) + +- template: shouldSign.yml + +- pwsh: | + $fullSymbolsFolder = '$(BinPath)' + Write-Verbose -Verbose "fullSymbolsFolder == $fullSymbolsFolder" + + Get-ChildItem -Recurse $fullSymbolsFolder | out-string | Write-Verbose -Verbose + + $filesToSignDirectory = "$(System.ArtifactsDirectory)\toBeSigned" + + if ((Test-Path -Path $filesToSignDirectory)) { + Remove-Item -Path $filesToSignDirectory -Recurse -Force + } + + $null = New-Item -ItemType Directory -Path $filesToSignDirectory -Force + + $signedFilesDirectory = "$(System.ArtifactsDirectory)\signed" + + if ((Test-Path -Path $signedFilesDirectory)) { + Remove-Item -Path $signedFilesDirectory -Recurse -Force + } + + $null = New-Item -ItemType Directory -Path $signedFilesDirectory -Force + + $itemsToCopyWithRecurse = @( + "$($fullSymbolsFolder)\*.ps1" + "$($fullSymbolsFolder)\Microsoft.PowerShell*.dll" + ) + + $itemsToCopy = @{ + "$($fullSymbolsFolder)\*.ps1" = "" + "$($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" + "$($fullSymbolsFolder)\pwsh.dll" = "" + "$($fullSymbolsFolder)\System.Management.Automation.dll" = "" + } + + ## Windows only modules + + if('$(ArtifactPlatform)' -eq 'windows') { + $itemsToCopy += @{ + "$($fullSymbolsFolder)\pwsh.exe" = "" + "$($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" + "$($fullSymbolsFolder)\Modules\Microsoft.PowerShell.Security\Security.types.ps1xml" = "Modules\Microsoft.PowerShell.Security" + "$($fullSymbolsFolder)\Modules\Microsoft.PowerShell.Diagnostics\Microsoft.PowerShell.Diagnostics.psd1" = "Modules\Microsoft.PowerShell.Diagnostics" + "$($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" + } + } + else { + $itemsToCopy += @{ + "$($fullSymbolsFolder)\pwsh" = "" + } + } + + $itemsToExclude = @( + # This package is retrieved from https://www.github.com/powershell/MarkdownRender + "$($fullSymbolsFolder)\Microsoft.PowerShell.MarkdownRender.dll" + ) + + Write-Verbose -verbose "recusively copying $($itemsToCopyWithRecurse | out-string) to $filesToSignDirectory" + Copy-Item -Path $itemsToCopyWithRecurse -Destination $filesToSignDirectory -Recurse -verbose -exclude $itemsToExclude + + 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: "$(AUTHENTICODE_CERT)" + pattern: | + **\*.dll + **\*.psd1 + **\*.psm1 + **\*.ps1xml + **\*.ps1 + **\*.exe + useMinimatch: true + shouldSign: $(SHOULD_SIGN) + displayName: Authenticode sign our binaries + +- pwsh: | + Import-Module $(PowerShellRoot)/build.psm1 -Force + Import-Module $(PowerShellRoot)/tools/packaging -Force + $signedFilesPath = '$(System.ArtifactsDirectory)\signed\' + $BuildPath = '$(BinPath)' + Write-Verbose -Verbose -Message "BuildPath: $BuildPath" + + Update-PSSignedBuildFolder -BuildPath $BuildPath -SignedFilesPath $SignedFilesPath + $dlls = Get-ChildItem $BuildPath\*.dll, $BuildPath\*.exe -Recurse + $signatures = $dlls | Get-AuthenticodeSignature + $missingSignatures = $signatures | Where-Object { $_.status -eq 'notsigned' -or $_.SignerCertificate.Issuer -notmatch '^CN=Microsoft.*'}| select-object -ExpandProperty Path + + Write-Verbose -verbose "to be signed:`r`n $($missingSignatures | Out-String)" + + $filesToSignDirectory = "$(System.ArtifactsDirectory)\thirdPartyToBeSigned" + if (Test-Path $filesToSignDirectory) { + Remove-Item -Path $filesToSignDirectory -Recurse -Force + } + + $null = New-Item -ItemType Directory -Path $filesToSignDirectory -Force -Verbose + + $signedFilesDirectory = "$(System.ArtifactsDirectory)\thirdPartySigned" + if (Test-Path $signedFilesDirectory) { + Remove-Item -Path $signedFilesDirectory -Recurse -Force + } + + $null = New-Item -ItemType Directory -Path $signedFilesDirectory -Force -Verbose + + $missingSignatures | ForEach-Object { + $pathWithoutLeaf = Split-Path $_ + $relativePath = $pathWithoutLeaf.replace($BuildPath,'') + Write-Verbose -Verbose -Message "relativePath: $relativePath" + $targetDirectory = Join-Path -Path $filesToSignDirectory -ChildPath $relativePath + Write-Verbose -Verbose -Message "targetDirectory: $targetDirectory" + if(!(Test-Path $targetDirectory)) + { + $null = New-Item -ItemType Directory -Path $targetDirectory -Force -Verbose + } + Copy-Item -Path $_ -Destination $targetDirectory + } + + displayName: Create ThirdParty Signing Folder + condition: and(succeeded(), eq(variables['SHOULD_SIGN'], 'true')) + +- template: EsrpSign.yml@ComplianceRepo + parameters: + buildOutputPath: $(System.ArtifactsDirectory)\thirdPartyToBeSigned + signOutputPath: $(System.ArtifactsDirectory)\thirdPartySigned + certificateId: "CP-231522" + pattern: | + **\*.dll + useMinimatch: true + shouldSign: $(SHOULD_SIGN) + displayName: Sign ThirdParty binaries + +- pwsh: | + Get-ChildItem '$(System.ArtifactsDirectory)\thirdPartySigned\*' + displayName: Capture ThirdParty Signed files + condition: and(succeeded(), eq(variables['SHOULD_SIGN'], 'true')) + +- pwsh: | + Import-Module '$(PowerShellRoot)/build.psm1' -Force + Import-Module '$(PowerShellRoot)/tools/packaging' -Force + $signedFilesPath = '$(System.ArtifactsDirectory)\thirdPartySigned' + $BuildPath = '$(BinPath)' + + Update-PSSignedBuildFolder -BuildPath $BuildPath -SignedFilesPath $SignedFilesPath + if ($env:BuildConfiguration -eq 'minSize') { + ## Remove XML files when making a min-size package. + Remove-Item "$BuildPath/*.xml" -Force + } + displayName: Merge ThirdParty signed files with Build + condition: and(succeeded(), eq(variables['SHOULD_SIGN'], 'true')) + +- pwsh: | + $uploadFolder = '$(BinPath)' + $containerName = '$(signedArtifactContainer)' + + Write-Verbose -Verbose "File permissions after signing" + Get-ChildItem $uploadFolder\pwsh | Select-Object -Property 'unixmode', 'size', 'name' + + $uploadTarFilePath = Join-Path '$(System.ArtifactsDirectory)' '$(signedBuildArtifactName)' + Write-Verbose -Verbose -Message "Creating tar.gz - $uploadTarFilePath" + tar -czvf $uploadTarFilePath -C $uploadFolder * + + Get-ChildItem '$(System.ArtifactsDirectory)' | Out-String | Write-Verbose -Verbose + + Write-Host "##vso[artifact.upload containerfolder=$containerName;artifactname=$containerName]$uploadTarFilePath" + displayName: Upload signed tar.gz files to artifacts + condition: eq(variables['ArtifactPlatform'], 'linux') + +- pwsh: | + $uploadFolder = '$(BinPath)' + $containerName = '$(signedArtifactContainer)' + + Get-ChildItem $uploadFolder -Recurse | Out-String | Write-Verbose -Verbose + + $uploadZipFilePath = Join-Path '$(System.ArtifactsDirectory)' 'PowerShell-$(Version)$(signedBuildArtifactName)' + Write-Verbose -Verbose -Message "Creating zip - $uploadZipFilePath" + Compress-Archive -Path $uploadFolder/* -DestinationPath $uploadZipFilePath -Verbose + + Get-ChildItem '$(System.ArtifactsDirectory)' | Out-String | Write-Verbose -Verbose + + Write-Host "##vso[artifact.upload containerfolder=$containerName;artifactname=$containerName]$uploadZipFilePath" + displayName: Upload signed zip files to artifacts + condition: eq(variables['ArtifactPlatform'], 'windows') + +- template: /tools/releaseBuild/azureDevOps/templates/step/finalize.yml diff --git a/tools/releaseBuild/azureDevOps/templates/windows-hosted-build.yml b/tools/releaseBuild/azureDevOps/templates/windows-hosted-build.yml index 1201edf98b7..7eec6f14460 100644 --- a/tools/releaseBuild/azureDevOps/templates/windows-hosted-build.yml +++ b/tools/releaseBuild/azureDevOps/templates/windows-hosted-build.yml @@ -14,7 +14,7 @@ jobs: condition: succeeded() dependsOn: ${{ parameters.parentJob }} pool: - name: PowerShell1ES + name: $(windowsPool) demands: - ImageOverride -equals PSMMS2019-Secure variables: diff --git a/tools/releaseBuild/azureDevOps/templates/windows-package-signing.yml b/tools/releaseBuild/azureDevOps/templates/windows-package-signing.yml index c2e3f4d1c1c..44b76127ddc 100644 --- a/tools/releaseBuild/azureDevOps/templates/windows-package-signing.yml +++ b/tools/releaseBuild/azureDevOps/templates/windows-package-signing.yml @@ -8,7 +8,7 @@ jobs: ${{ parameters.parentJobs }} condition: succeeded() pool: - name: PowerShell1ES + name: $(windowsPool) demands: - ImageOverride -equals PSMMS2019-Secure variables: diff --git a/tools/releaseBuild/azureDevOps/templates/windows-packaging.yml b/tools/releaseBuild/azureDevOps/templates/windows-packaging.yml index 6692f296f39..e6b3bb91f49 100644 --- a/tools/releaseBuild/azureDevOps/templates/windows-packaging.yml +++ b/tools/releaseBuild/azureDevOps/templates/windows-packaging.yml @@ -12,9 +12,8 @@ jobs: - job: sign_windows_${{ parameters.Architecture }}_${{ parameters.BuildConfiguration }} displayName: Package Windows - ${{ parameters.Architecture }} ${{ parameters.BuildConfiguration }} condition: succeeded() - dependsOn: ${{ parameters.parentJob }} pool: - name: PowerShell1ES + name: $(windowsPool) demands: - ImageOverride -equals PSMMS2019-Secure variables: From ab0e9d58faa8a2854dbefef5b573dad9e8042765 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Wed, 15 Mar 2023 17:37:06 -0700 Subject: [PATCH 09/18] Fix issues in release build and release pipeline (#19338) --- tools/releaseBuild/azureDevOps/releaseBuild.yml | 8 ++++++++ tools/releaseBuild/azureDevOps/releasePipeline.yml | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/releaseBuild/azureDevOps/releaseBuild.yml b/tools/releaseBuild/azureDevOps/releaseBuild.yml index 98d7279883f..192a5f37f28 100644 --- a/tools/releaseBuild/azureDevOps/releaseBuild.yml +++ b/tools/releaseBuild/azureDevOps/releaseBuild.yml @@ -320,6 +320,14 @@ stages: jobs: - template: templates/windows-package-signing.yml + - template: templates/mac-package-signing.yml + parameters: + buildArchitecture: x64 + + - template: templates/mac-package-signing.yml + parameters: + buildArchitecture: arm64 + # This is done late so that we dont use resources before the big signing and packaging tasks. - stage: compliance dependsOn: ['package_signing'] diff --git a/tools/releaseBuild/azureDevOps/releasePipeline.yml b/tools/releaseBuild/azureDevOps/releasePipeline.yml index bd52a99b844..7e474c3acb6 100644 --- a/tools/releaseBuild/azureDevOps/releasePipeline.yml +++ b/tools/releaseBuild/azureDevOps/releasePipeline.yml @@ -175,6 +175,7 @@ stages: jobs: - job: KickOffRA displayName: Kickoff Release Automation + timeoutInMinutes: 240 pool: name: PowerShell1ES @@ -257,7 +258,6 @@ stages: - StaticPkgValidation - StartDocker - ManualValidation - - ReleaseAutomation - ValidateFxdPackage - ValidateGlobalTool @@ -557,7 +557,7 @@ stages: $isPreview = $semanticVersion.PreReleaseLabel -ne $null if (-not $isPreview) { - $buildInvocationInfo = Start-AzDOBuild -BuildDefinitionId 1238 -Tag $metadata.ReleaseVersion, 'InProgress' -PassThru + $buildInvocationInfo = Start-AzDOBuild -BuildDefinitionId 1238 -Branch '$(Build.SourceBranch)' -Tag $metadata.ReleaseVersion, 'InProgress' -PassThru Write-Verbose -Verbose "Kicked off vPack build: $($buildInvocationInfo.WebUrl)" $status = $buildInvocationInfo | Wait-AzDOBuildStatus -Status Completed -timeoutMinutes 60 if ($status.result -ne 'Succeeded') { From 1aa4a36a5e577ea0770eed72921e97e26b6647ff Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Mon, 20 Mar 2023 15:43:49 -0700 Subject: [PATCH 10/18] Fix stage dependencies and typo in release build (#19353) --- tools/releaseBuild/azureDevOps/releaseBuild.yml | 8 ++++---- .../azureDevOps/templates/mac-package-signing.yml | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/releaseBuild/azureDevOps/releaseBuild.yml b/tools/releaseBuild/azureDevOps/releaseBuild.yml index 192a5f37f28..02b0f1cd4af 100644 --- a/tools/releaseBuild/azureDevOps/releaseBuild.yml +++ b/tools/releaseBuild/azureDevOps/releaseBuild.yml @@ -321,12 +321,12 @@ stages: - template: templates/windows-package-signing.yml - template: templates/mac-package-signing.yml - parameters: - buildArchitecture: x64 + parameters: + buildArchitecture: x64 - template: templates/mac-package-signing.yml - parameters: - buildArchitecture: arm64 + parameters: + buildArchitecture: arm64 # This is done late so that we dont use resources before the big signing and packaging tasks. - stage: compliance diff --git a/tools/releaseBuild/azureDevOps/templates/mac-package-signing.yml b/tools/releaseBuild/azureDevOps/templates/mac-package-signing.yml index c0fea010973..b4b6f05821b 100644 --- a/tools/releaseBuild/azureDevOps/templates/mac-package-signing.yml +++ b/tools/releaseBuild/azureDevOps/templates/mac-package-signing.yml @@ -4,7 +4,6 @@ parameters: jobs: - job: MacPackageSigningJob_${{ parameters.buildArchitecture }} displayName: macOS Package signing ${{ parameters.buildArchitecture }} - dependsOn: package_macOS_${{ parameters.buildArchitecture }} condition: succeeded() pool: name: PowerShell1ES From 2e14410d152600339c1a13414967bfa7d504e63b Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Mon, 10 Apr 2023 10:34:34 -0700 Subject: [PATCH 11/18] Try to fix the build --- build.psm1 | 33 ---- .../templates/linux-authenticode-sign.yml | 154 --------------- .../azureDevOps/templates/sign-build-file.yml | 1 - .../azureDevOps/templates/signBuildFiles.yml | 187 ------------------ 4 files changed, 375 deletions(-) delete mode 100644 tools/releaseBuild/azureDevOps/templates/linux-authenticode-sign.yml delete mode 100644 tools/releaseBuild/azureDevOps/templates/signBuildFiles.yml diff --git a/build.psm1 b/build.psm1 index 4dc2dbe34a9..c05b7a79dfc 100644 --- a/build.psm1 +++ b/build.psm1 @@ -1050,36 +1050,6 @@ function Get-PesterTag { $o } -# Function to build and publish the Microsoft.PowerShell.NamedPipeConnection module for -# testing PowerShell remote custom connections. -function Publish-CustomConnectionTestModule -{ - $sourcePath = "${PSScriptRoot}/test/tools/NamedPipeConnection" - $outPath = "${PSScriptRoot}/test/tools/NamedPipeConnection/out/Microsoft.PowerShell.NamedPipeConnection" - $publishPath = "${PSScriptRoot}/test/tools/Modules" - - Find-DotNet - - Push-Location -Path $sourcePath - try { - # Build the Microsoft.PowerShell.NamedPipeConnect module - ./build.ps1 -Clean -Build - - if (! (Test-Path -Path $outPath)) { - throw "Publish-CustomConnectionTestModule: Build failed. Output path does not exist: $outPath" - } - - # Publish the Microsoft.PowerShell.NamedPipeConnection module - Copy-Item -Path $outPath -Destination $publishPath -Recurse -Force - - # Clean up build artifacts - ./build.ps1 -Clean - } - finally { - Pop-Location - } -} - function Publish-PSTestTools { [CmdletBinding()] param( @@ -1129,9 +1099,6 @@ function Publish-PSTestTools { # `dotnet restore` on test project is not called if product projects have been restored unless -Force is specified. Copy-PSGalleryModules -Destination "${PSScriptRoot}/test/tools/Modules" -CsProjPath "$PSScriptRoot/test/tools/Modules/PSGalleryTestModules.csproj" -Force - - # Publish the Microsoft.PowerShell.NamedPipeConnection module - Publish-CustomConnectionTestModule } function Get-ExperimentalFeatureTests { diff --git a/tools/releaseBuild/azureDevOps/templates/linux-authenticode-sign.yml b/tools/releaseBuild/azureDevOps/templates/linux-authenticode-sign.yml deleted file mode 100644 index 569cdbffd6f..00000000000 --- a/tools/releaseBuild/azureDevOps/templates/linux-authenticode-sign.yml +++ /dev/null @@ -1,154 +0,0 @@ -jobs: -- job: sign_linux_builds - displayName: Sign all linux builds - condition: succeeded() - pool: - name: PowerShell1ES - demands: - - ImageOverride -equals PSMMS2019-Secure - dependsOn: ['build_fxdependent', 'build_rpm'] - variables: - - name: runCodesignValidationInjection - value: false - - name: NugetSecurityAnalysisWarningLevel - value: none - - group: ESRP - - steps: - - checkout: self - clean: true - - - task: DownloadPipelineArtifact@2 - inputs: - artifact: pwshLinuxBuild.tar.gz - path: $(Build.ArtifactStagingDirectory)/linuxTars - displayName: Download deb build - - - task: DownloadPipelineArtifact@2 - inputs: - artifact: pwshLinuxBuildMinSize.tar.gz - path: $(Build.ArtifactStagingDirectory)/linuxTars - displayName: Download min-size build - - - task: DownloadPipelineArtifact@2 - inputs: - artifact: pwshLinuxBuildArm32.tar.gz - path: $(Build.ArtifactStagingDirectory)/linuxTars - displayName: Download arm32 build - - - task: DownloadPipelineArtifact@2 - inputs: - artifact: pwshLinuxBuildArm64.tar.gz - path: $(Build.ArtifactStagingDirectory)/linuxTars - displayName: Download arm64 build - - - task: DownloadPipelineArtifact@2 - inputs: - artifact: pwshMarinerBuildAmd64.tar.gz - path: $(Build.ArtifactStagingDirectory)/linuxTars - displayName: Download mariner build - - - task: DownloadPipelineArtifact@2 - inputs: - artifact: pwshLinuxBuildAlpine.tar.gz - path: $(Build.ArtifactStagingDirectory)/linuxTars/pwshLinuxBuildAlpine.tar.gz - displayName: Download alpine build - - - task: DownloadPipelineArtifact@2 - inputs: - artifact: pwshLinuxBuildFxdependent.tar.gz - path: $(Build.ArtifactStagingDirectory)/linuxTars/pwshLinuxBuildFxdependent.tar.gz - displayName: Download fxdependent build - - - pwsh: | - Get-ChildItem -Path $(Build.ArtifactStagingDirectory)/linuxTars - displayName: Capture downloaded tars - - - pwsh: | - Write-Verbose -Verbose -Message "Expanding $(Build.ArtifactStagingDirectory)/linuxTars/pwshLinuxBuild.tar.gz to $(Build.ArtifactStagingDirectory)/pwshLinuxBuild" - New-Item -Path $(Build.ArtifactStagingDirectory)/pwshLinuxBuild -ItemType Directory - tar -xf $(Build.ArtifactStagingDirectory)/linuxTars/pwshLinuxBuild.tar.gz -C $(Build.ArtifactStagingDirectory)/pwshLinuxBuild - Write-Verbose -Verbose "File permisions after expanding" - Get-ChildItem -Path $(Build.ArtifactStagingDirectory)/pwshLinuxBuild/pwsh | Select-Object -Property 'unixmode', 'size', 'name' - - Write-Verbose -Verbose -Message "Expanding $(Build.ArtifactStagingDirectory)/linuxTars/pwshLinuxBuildMinSize.tar.gz to $(Build.ArtifactStagingDirectory)/pwshLinuxBuildMinSize" - New-Item -Path $(Build.ArtifactStagingDirectory)/pwshLinuxBuildMinSize -ItemType Directory - tar -xf $(Build.ArtifactStagingDirectory)/linuxTars/pwshLinuxBuildMinSize.tar.gz -C $(Build.ArtifactStagingDirectory)/pwshLinuxBuildMinSize - - Write-Verbose -Verbose -Message "Expanding $(Build.ArtifactStagingDirectory)/linuxTars/pwshLinuxBuildArm32.tar.gz to $(Build.ArtifactStagingDirectory)/pwshLinuxBuildArm32" - New-Item -Path $(Build.ArtifactStagingDirectory)/pwshLinuxBuildArm32 -ItemType Directory - tar -xf $(Build.ArtifactStagingDirectory)/linuxTars/pwshLinuxBuildArm32.tar.gz -C $(Build.ArtifactStagingDirectory)/pwshLinuxBuildArm32 - - Write-Verbose -Verbose -Message "Expanding $(Build.ArtifactStagingDirectory)/linuxTars/pwshLinuxBuildArm64.tar.gz to $(Build.ArtifactStagingDirectory)/pwshLinuxBuildArm64" - New-Item -Path $(Build.ArtifactStagingDirectory)/pwshLinuxBuildArm64 -ItemType Directory - tar -xf $(Build.ArtifactStagingDirectory)/linuxTars/pwshLinuxBuildArm64.tar.gz -C $(Build.ArtifactStagingDirectory)/pwshLinuxBuildArm64 - - Write-Verbose -Verbose -Message "Expanding $(Build.ArtifactStagingDirectory)/linuxTars/pwshMarinerBuildAmd64.tar.gz to $(Build.ArtifactStagingDirectory)/pwshMarinerBuildAmd64" - New-Item -Path $(Build.ArtifactStagingDirectory)/pwshMarinerBuildAmd64 -ItemType Directory - tar -xf $(Build.ArtifactStagingDirectory)/linuxTars/pwshMarinerBuildAmd64.tar.gz -C $(Build.ArtifactStagingDirectory)/pwshMarinerBuildAmd64 - - Write-Verbose -Verbose -Message "Expanding $(Build.ArtifactStagingDirectory)/linuxTars/pwshLinuxBuildAlpine.tar.gz/pwshLinuxBuild.tar.gz to $(Build.ArtifactStagingDirectory)/pwshLinuxBuildAlpine" - New-Item -Path $(Build.ArtifactStagingDirectory)/pwshLinuxBuildAlpine -ItemType Directory - tar -xf $(Build.ArtifactStagingDirectory)/linuxTars/pwshLinuxBuildAlpine.tar.gz/pwshLinuxBuild.tar.gz -C $(Build.ArtifactStagingDirectory)/pwshLinuxBuildAlpine - - Write-Verbose -Verbose -Message "Expanding $(Build.ArtifactStagingDirectory)/linuxTars/pwshLinuxBuildFxdependent.tar.gz/pwshLinuxBuild.tar.gz to $(Build.ArtifactStagingDirectory)/pwshLinuxBuildFxdependent" - New-Item -Path $(Build.ArtifactStagingDirectory)/pwshLinuxBuildFxdependent -ItemType Directory - tar -xf $(Build.ArtifactStagingDirectory)/linuxTars/pwshLinuxBuildFxdependent.tar.gz/pwshLinuxBuild.tar.gz -C $(Build.ArtifactStagingDirectory)/pwshLinuxBuildFxdependent - displayName: Expand builds - - - template: SetVersionVariables.yml - parameters: - ReleaseTagVar: $(ReleaseTagVar) - - - template: cloneToOfficialPath.yml - - - template: insert-nuget-config-azfeed.yml - parameters: - repoRoot: $(PowerShellRoot) - - - powershell: | - Set-Location $env:POWERSHELLROOT - import-module "$env:POWERSHELLROOT/build.psm1" - Sync-PSTags -AddRemoteIfMissing - displayName: SyncTags - condition: and(succeeded(), ne(variables['SkipBuild'], 'true')) - - - checkout: ComplianceRepo - clean: true - - - template: shouldSign.yml - - - template: signBuildFiles.yml - parameters: - binLocation: pwshLinuxBuild - buildPrefixName: 'PowerShell Linux' - - - template: signBuildFiles.yml - parameters: - binLocation: pwshLinuxBuildMinSize - buildPrefixName: 'PowerShell Linux Minimum Size' - - - template: signBuildFiles.yml - parameters: - binLocation: pwshLinuxBuildArm32 - buildPrefixName: 'PowerShell Linux Arm32' - - - template: signBuildFiles.yml - parameters: - binLocation: pwshLinuxBuildArm64 - buildPrefixName: 'PowerShell Linux Arm64' - - - template: signBuildFiles.yml - parameters: - binLocation: pwshMarinerBuildAmd64 - buildPrefixName: 'PowerShell Linux x64 Framework Dependent' - - - template: signBuildFiles.yml - parameters: - binLocation: pwshLinuxBuildAlpine - buildPrefixName: 'PowerShell Linux Alpine x64' - - - template: signBuildFiles.yml - parameters: - binLocation: pwshLinuxBuildFxdependent - buildPrefixName: 'PowerShell Linux Framework Dependent' diff --git a/tools/releaseBuild/azureDevOps/templates/sign-build-file.yml b/tools/releaseBuild/azureDevOps/templates/sign-build-file.yml index cfa172796d8..08bd71d1564 100644 --- a/tools/releaseBuild/azureDevOps/templates/sign-build-file.yml +++ b/tools/releaseBuild/azureDevOps/templates/sign-build-file.yml @@ -169,7 +169,6 @@ steps: "$($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" - "$($fullSymbolsFolder)\Modules\Microsoft.PowerShell.Security\Security.types.ps1xml" = "Modules\Microsoft.PowerShell.Security" "$($fullSymbolsFolder)\Modules\Microsoft.PowerShell.Diagnostics\Microsoft.PowerShell.Diagnostics.psd1" = "Modules\Microsoft.PowerShell.Diagnostics" "$($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" diff --git a/tools/releaseBuild/azureDevOps/templates/signBuildFiles.yml b/tools/releaseBuild/azureDevOps/templates/signBuildFiles.yml deleted file mode 100644 index f8a252da21c..00000000000 --- a/tools/releaseBuild/azureDevOps/templates/signBuildFiles.yml +++ /dev/null @@ -1,187 +0,0 @@ -parameters: - binLocation: '' - buildPrefixName: '' - addWindowsModules: 'false' - -steps: -- pwsh: | - $fullSymbolsFolder = Join-Path $(System.ArtifactsDirectory) "${{ parameters.binLocation }}" - - Write-Verbose -Verbose "fullSymbolsFolder == $fullSymbolsFolder" - - Get-ChildItem -Recurse $fullSymbolsFolder | out-string | Write-Verbose -Verbose - - $filesToSignDirectory = "$(System.ArtifactsDirectory)\toBeSigned" - - if ((Test-Path -Path $filesToSignDirectory)) { - Remove-Item -Path $filesToSignDirectory -Recurse -Force - } - - $null = New-Item -ItemType Directory -Path $filesToSignDirectory -Force - - $signedFilesDirectory = "$(System.ArtifactsDirectory)\signed" - - if ((Test-Path -Path $signedFilesDirectory)) { - Remove-Item -Path $signedFilesDirectory -Recurse -Force - } - - $null = New-Item -ItemType Directory -Path $signedFilesDirectory -Force - - $itemsToCopyWithRecurse = @( - "$($fullSymbolsFolder)\*.ps1" - "$($fullSymbolsFolder)\Microsoft.PowerShell*.dll" - ) - - $itemsToCopy = @{ - "$($fullSymbolsFolder)\*.ps1" = "" - "$($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" - "$($fullSymbolsFolder)\pwsh.dll" = "" - "$($fullSymbolsFolder)\System.Management.Automation.dll" = "" - } - - ## Windows only modules - - if('${{ parameters.addWindowsModules }}' -ne 'false') { - $itemsToCopy += @{ - "$($fullSymbolsFolder)\pwsh.exe" = "" - "$($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" - "$($fullSymbolsFolder)\Modules\Microsoft.PowerShell.Security\Security.types.ps1xml" = "Modules\Microsoft.PowerShell.Security" - "$($fullSymbolsFolder)\Modules\Microsoft.PowerShell.Diagnostics\Microsoft.PowerShell.Diagnostics.psd1" = "Modules\Microsoft.PowerShell.Diagnostics" - "$($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" - } - } - else { - $itemsToCopy += @{ - "$($fullSymbolsFolder)\pwsh" = "" - } - } - - $itemsToExclude = @( - # This package is retrieved from https://www.github.com/powershell/MarkdownRender - "$($fullSymbolsFolder)\Microsoft.PowerShell.MarkdownRender.dll" - ) - - Write-Verbose -verbose "recusively copying $($itemsToCopyWithRecurse | out-string) to $filesToSignDirectory" - Copy-Item -Path $itemsToCopyWithRecurse -Destination $filesToSignDirectory -Recurse -verbose -exclude $itemsToExclude - - 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: '${{ parameters.buildPrefixName }} - Prepare files to be signed' - -- template: EsrpSign.yml@ComplianceRepo - parameters: - buildOutputPath: $(System.ArtifactsDirectory)\toBeSigned - signOutputPath: $(System.ArtifactsDirectory)\signed - certificateId: "$(AUTHENTICODE_CERT)" - pattern: | - **\*.dll - **\*.psd1 - **\*.psm1 - **\*.ps1xml - **\*.ps1 - **\*.exe - useMinimatch: true - shouldSign: $(SHOULD_SIGN) - displayName: ${{ parameters.buildPrefixName }} - Authenticode - -- pwsh: | - Import-Module $(PowerShellRoot)/build.psm1 -Force - Import-Module $(PowerShellRoot)/tools/packaging -Force - $signedFilesPath = '$(System.ArtifactsDirectory)\signed\' - $BuildPath = Join-Path $(System.ArtifactsDirectory) '${{ parameters.binLocation }}' - Write-Verbose -Verbose -Message "BuildPath: $BuildPath" - - Update-PSSignedBuildFolder -BuildPath $BuildPath -SignedFilesPath $SignedFilesPath - $dlls = Get-ChildItem $BuildPath\*.dll, $BuildPath\*.exe -Recurse - $signatures = $dlls | Get-AuthenticodeSignature - $missingSignatures = $signatures | Where-Object { $_.status -eq 'notsigned' -or $_.SignerCertificate.Issuer -notmatch '^CN=Microsoft.*'}| select-object -ExpandProperty Path - - Write-Verbose -verbose "to be signed:`r`n $($missingSignatures | Out-String)" - - $filesToSignDirectory = "$(System.ArtifactsDirectory)\thirdPartyToBeSigned" - if (Test-Path $filesToSignDirectory) { - Remove-Item -Path $filesToSignDirectory -Recurse -Force - } - - $null = New-Item -ItemType Directory -Path $filesToSignDirectory -Force -Verbose - - $signedFilesDirectory = "$(System.ArtifactsDirectory)\thirdPartySigned" - if (Test-Path $signedFilesDirectory) { - Remove-Item -Path $signedFilesDirectory -Recurse -Force - } - - $null = New-Item -ItemType Directory -Path $signedFilesDirectory -Force -Verbose - - $missingSignatures | ForEach-Object { - $pathWithoutLeaf = Split-Path $_ - $relativePath = $pathWithoutLeaf.replace($BuildPath,'') - Write-Verbose -Verbose -Message "relativePath: $relativePath" - $targetDirectory = Join-Path -Path $filesToSignDirectory -ChildPath $relativePath - Write-Verbose -Verbose -Message "targetDirectory: $targetDirectory" - if(!(Test-Path $targetDirectory)) - { - $null = New-Item -ItemType Directory -Path $targetDirectory -Force -Verbose - } - Copy-Item -Path $_ -Destination $targetDirectory - } - - displayName: ${{ parameters.buildPrefixName }} - Create ThirdParty Signing Folder - condition: and(succeeded(), eq(variables['SHOULD_SIGN'], 'true')) - -- template: EsrpSign.yml@ComplianceRepo - parameters: - buildOutputPath: $(System.ArtifactsDirectory)\thirdPartyToBeSigned - signOutputPath: $(System.ArtifactsDirectory)\thirdPartySigned - certificateId: "CP-231522" - pattern: | - **\*.dll - useMinimatch: true - shouldSign: $(SHOULD_SIGN) - displayName: Sign ThirdParty binaries - -- pwsh: | - Get-ChildItem '$(System.ArtifactsDirectory)\thirdPartySigned\*' - displayName: ${{ parameters.buildPrefixName }} - Capture ThirdParty Signed files - condition: and(succeeded(), eq(variables['SHOULD_SIGN'], 'true')) - -- pwsh: | - Import-Module $(PowerShellRoot)/build.psm1 -Force - Import-Module $(PowerShellRoot)/tools/packaging -Force - $signedFilesPath = '$(System.ArtifactsDirectory)\thirdPartySigned' - $BuildPath = Join-Path $(System.ArtifactsDirectory) '${{ parameters.binLocation }}' - - Update-PSSignedBuildFolder -BuildPath $BuildPath -SignedFilesPath $SignedFilesPath - if ($env:BuildConfiguration -eq 'minSize') { - ## Remove XML files when making a min-size package. - Remove-Item "$BuildPath/*.xml" -Force - } - displayName: ${{ parameters.buildPrefixName }} - Merge ThirdParty signed files with Build - condition: and(succeeded(), eq(variables['SHOULD_SIGN'], 'true')) - -- pwsh: | - $uploadFolder = '$(System.ArtifactsDirectory)/${{ parameters.binLocation }}' - $containerName = 'authenticode-signed' - - Write-Verbose -Verbose "File permissions after signing" - Get-ChildItem $uploadFolder\pwsh | Select-Object -Property 'unixmode', 'size', 'name' - - $uploadTarFilePath = '$(System.ArtifactsDirectory)/${{ parameters.binLocation }}.tar.gz' - Write-Verbose -Verbose -Message "Creating tar.gz - $uploadTarFilePath" - tar -czvf $uploadTarFilePath -C $uploadFolder * - - Write-Host "##vso[artifact.upload containerfolder=$containerName;artifactname=$containerName]$uploadTarFilePath" - displayName: ${{ parameters.buildPrefixName }} - Upload signed files to artifacts From 84ff770ba77e084eb7c0580e193eabaacba2e08f Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Tue, 11 Apr 2023 12:11:51 -0700 Subject: [PATCH 12/18] Update .NET SDK to 6.0.408 --- global.json | 2 +- src/Microsoft.PowerShell.SDK/Microsoft.PowerShell.SDK.csproj | 2 +- .../System.Management.Automation.csproj | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/global.json b/global.json index 50606936ab7..d5aa2bf7bf4 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "6.0.406" + "version": "6.0.408" } } diff --git a/src/Microsoft.PowerShell.SDK/Microsoft.PowerShell.SDK.csproj b/src/Microsoft.PowerShell.SDK/Microsoft.PowerShell.SDK.csproj index 9587c69e4b5..56318cd3732 100644 --- a/src/Microsoft.PowerShell.SDK/Microsoft.PowerShell.SDK.csproj +++ b/src/Microsoft.PowerShell.SDK/Microsoft.PowerShell.SDK.csproj @@ -31,7 +31,7 @@ - + diff --git a/src/System.Management.Automation/System.Management.Automation.csproj b/src/System.Management.Automation/System.Management.Automation.csproj index 62897f9816d..ce00d3023ca 100644 --- a/src/System.Management.Automation/System.Management.Automation.csproj +++ b/src/System.Management.Automation/System.Management.Automation.csproj @@ -12,7 +12,7 @@ - + @@ -25,7 +25,7 @@ - + From 7c8152dafb7784929048e7ab87ed74534382a01f Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Tue, 11 Apr 2023 13:56:05 -0700 Subject: [PATCH 13/18] Update the wix file --- assets/wix/files.wxs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/wix/files.wxs b/assets/wix/files.wxs index 5cbab86595b..648be68c409 100644 --- a/assets/wix/files.wxs +++ b/assets/wix/files.wxs @@ -3154,8 +3154,8 @@ - - + + @@ -4173,7 +4173,7 @@ - + From f728e44c5b34f2d45823af2e2e5cc3143c046872 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Tue, 11 Apr 2023 17:03:00 -0700 Subject: [PATCH 14/18] Fix the template that creates nuget package --- .../azureDevOps/templates/nuget-pkg-sbom.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/releaseBuild/azureDevOps/templates/nuget-pkg-sbom.yml b/tools/releaseBuild/azureDevOps/templates/nuget-pkg-sbom.yml index f0a033fd9e4..b57ed223cae 100644 --- a/tools/releaseBuild/azureDevOps/templates/nuget-pkg-sbom.yml +++ b/tools/releaseBuild/azureDevOps/templates/nuget-pkg-sbom.yml @@ -44,13 +44,13 @@ steps: Start-PSBuild -Clean -Runtime linux-x64 -Configuration Release $sharedModules | Foreach-Object { - $refFile = Get-ChildItem -Path "$env:REPOROOT\src\$_\obj\Release\net8.0\refint\$_.dll" + $refFile = Get-ChildItem -Path "$env:REPOROOT\src\$_\obj\Release\net6.0\refint\$_.dll" Write-Verbose -Verbose "RefAssembly: $refFile" Copy-Item -Path $refFile -Destination "$refAssemblyFolder\$_.dll" -Verbose - $refDoc = "$env:REPOROOT\src\$_\bin\Release\net8.0\$_.xml" + $refDoc = "$env:REPOROOT\src\$_\bin\Release\net6.0\$_.xml" if (-not (Test-Path $refDoc)) { Write-Warning "$refDoc not found" - Get-ChildItem -Path "$env:REPOROOT\src\$_\bin\Release\net8.0\" | Out-String | Write-Verbose -Verbose + Get-ChildItem -Path "$env:REPOROOT\src\$_\bin\Release\net6.0\" | Out-String | Write-Verbose -Verbose } else { Copy-Item -Path $refDoc -Destination "$refAssemblyFolder\$_.xml" -Verbose @@ -60,13 +60,13 @@ steps: Start-PSBuild -Clean -Runtime win7-x64 -Configuration Release $winOnlyModules | Foreach-Object { - $refFile = Get-ChildItem -Path "$env:REPOROOT\src\$_\obj\Release\net8.0\refint\*.dll" + $refFile = Get-ChildItem -Path "$env:REPOROOT\src\$_\obj\Release\net6.0\refint\*.dll" Write-Verbose -Verbose 'RefAssembly: $refFile' Copy-Item -Path $refFile -Destination "$refAssemblyFolder\$_.dll" -Verbose - $refDoc = "$env:REPOROOT\src\$_\bin\Release\net8.0\$_.xml" + $refDoc = "$env:REPOROOT\src\$_\bin\Release\net6.0\$_.xml" if (-not (Test-Path $refDoc)) { Write-Warning "$refDoc not found" - Get-ChildItem -Path "$env:REPOROOT\src\$_\bin\Release\net8.0" | Out-String | Write-Verbose -Verbose + Get-ChildItem -Path "$env:REPOROOT\src\$_\bin\Release\net6.0" | Out-String | Write-Verbose -Verbose } else { Copy-Item -Path $refDoc -Destination "$refAssemblyFolder\$_.xml" -Verbose From e08f9eeeb64da99cc88a97d992335f3b26dae963 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Tue, 11 Apr 2023 17:46:57 -0700 Subject: [PATCH 15/18] Update cgmanifest.json --- tools/cgmanifest.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/cgmanifest.json b/tools/cgmanifest.json index 5729e5e21ba..d1b8d2cfe5d 100644 --- a/tools/cgmanifest.json +++ b/tools/cgmanifest.json @@ -165,7 +165,7 @@ "Type": "nuget", "Nuget": { "Name": "Microsoft.PowerShell.Native", - "Version": "7.2.0" + "Version": "7.2.1" } }, "DevelopmentDependency": false @@ -205,7 +205,7 @@ "Type": "nuget", "Nuget": { "Name": "Microsoft.Windows.Compatibility", - "Version": "6.0.2" + "Version": "6.0.4" } }, "DevelopmentDependency": false @@ -225,7 +225,7 @@ "Type": "nuget", "Nuget": { "Name": "Newtonsoft.Json", - "Version": "13.0.2" + "Version": "13.0.3" } }, "DevelopmentDependency": false @@ -515,7 +515,7 @@ "Type": "nuget", "Nuget": { "Name": "System.DirectoryServices", - "Version": "6.0.0" + "Version": "6.0.1" } }, "DevelopmentDependency": false @@ -565,7 +565,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Management", - "Version": "6.0.0" + "Version": "6.0.1" } }, "DevelopmentDependency": false @@ -675,7 +675,7 @@ "Type": "nuget", "Nuget": { "Name": "System.Security.Cryptography.Pkcs", - "Version": "6.0.1" + "Version": "6.0.2" } }, "DevelopmentDependency": false From 183e2411a56f5fe8c7eeb88ec64840365c6eacc1 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Tue, 11 Apr 2023 17:55:12 -0700 Subject: [PATCH 16/18] Update ThirdPartyNotices.txt --- ThirdPartyNotices.txt | 184 +++++------------------------------------- 1 file changed, 22 insertions(+), 162 deletions(-) diff --git a/ThirdPartyNotices.txt b/ThirdPartyNotices.txt index d2660ab5dde..f2be44146b2 100644 --- a/ThirdPartyNotices.txt +++ b/ThirdPartyNotices.txt @@ -399,10 +399,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI --------------------------------------------------------- -Microsoft.PowerShell.Native 7.2.0 - MIT +Microsoft.PowerShell.Native 7.2.1 - MIT -(c) Microsoft Corporation. +(c) Microsoft Corporation Copyright (c) by P.J. Plauger MIT License @@ -612,81 +612,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ---------------------------------------------------------- - ---------------------------------------------------------- - -Microsoft.Windows.Compatibility 6.0.2 - MIT - - -(c) Microsoft Corporation -Copyright (c) Andrew Arnott -Copyright 2019 LLVM Project -Copyright 2018 Daniel Lemire -Copyright (c) .NET Foundation -Copyright (c) 2011, Google Inc. -Copyright (c) 2020 Dan Shechter -(c) 1997-2005 Sean Eron Anderson -Copyright (c) 1998 Microsoft. To -Copyright (c) 2017 Yoshifumi Kawai -Copyright (c) 2005-2020 Rich Felker -Copyright (c) Microsoft Corporation -Copyright (c) 2007 James Newton-King -Copyright (c) 2012-2014, Yann Collet -Copyright (c) 1991-2020 Unicode, Inc. -Copyright (c) 2013-2017, Alfred Klomp -Copyright 2012 the V8 project authors -Copyright (c) 2011-2020 Microsoft Corp -Copyright (c) 2015-2017, Wojciech Mula -Copyright (c) 2005-2007, Nick Galbreath -Copyright (c) 2015 The Chromium Authors -Copyright (c) 2018 Alexander Chermyanin -Copyright (c) The Internet Society 1997 -Portions (c) International Organization -Copyright (c) 2004-2006 Intel Corporation -Copyright (c) 2013-2017, Milosz Krajewski -Copyright (c) 2016-2017, Matthieu Darbois -Copyright (c) The Internet Society (2003) -Copyright (c) .NET Foundation Contributors -Copyright (c) .NET Foundation and Contributors -Copyright (c) 2019 Microsoft Corporation, Daan Leijen -Copyright (c) 2011 Novell, Inc (http://www.novell.com) -Copyright (c) 1995-2017 Jean-loup Gailly and Mark Adler -Copyright (c) 2015 Xamarin, Inc (http://www.xamarin.com) -Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors -Copyright (c) 2014 Ryan Juckett http://www.ryanjuckett.com -Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc. -Copyright (c) YEAR W3C(r) (MIT, ERCIM, Keio, Beihang). Disclaimers -Copyright (c) 2015 THL A29 Limited, a Tencent company, and Milo Yip -Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 The Regents of the University of California -Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. & Digital Equipment Corporation, Maynard, Mass -Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. & Digital Equipment Corporation, Maynard, Mass. To - -The MIT License (MIT) - -Copyright (c) .NET Foundation and Contributors - -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - - --------------------------------------------------------- --------------------------------------------------------- @@ -709,7 +634,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI --------------------------------------------------------- -Newtonsoft.Json 13.0.2 - MIT +Newtonsoft.Json 13.0.3 - MIT Copyright James Newton-King 2008 @@ -2001,45 +1926,50 @@ SOFTWARE. --------------------------------------------------------- -System.DirectoryServices 6.0.0 - MIT +System.DirectoryServices 6.0.1 - MIT -(c) Microsoft Corporation. +(c) Microsoft Corporation Copyright (c) Andrew Arnott +Copyright 2019 LLVM Project Copyright 2018 Daniel Lemire -Copyright 2012 the V8 project -Copyright (c) .NET Foundation. +Copyright (c) .NET Foundation Copyright (c) 2011, Google Inc. +Copyright (c) 2020 Dan Shechter +(c) 1997-2005 Sean Eron Anderson Copyright (c) 1998 Microsoft. To -(c) 1997-2005 Sean Eron Anderson. Copyright (c) 2017 Yoshifumi Kawai +Copyright (c) 2005-2020 Rich Felker Copyright (c) Microsoft Corporation Copyright (c) 2007 James Newton-King Copyright (c) 2012-2014, Yann Collet +Copyright (c) 1991-2020 Unicode, Inc. Copyright (c) 2013-2017, Alfred Klomp +Copyright 2012 the V8 project authors +Copyright (c) 2011-2020 Microsoft Corp Copyright (c) 2015-2017, Wojciech Mula Copyright (c) 2005-2007, Nick Galbreath +Copyright (c) 2015 The Chromium Authors Copyright (c) 2018 Alexander Chermyanin +Copyright (c) The Internet Society 1997 Portions (c) International Organization -Copyright (c) 2015 The Chromium Authors. -Copyright (c) The Internet Society 1997. Copyright (c) 2004-2006 Intel Corporation Copyright (c) 2013-2017, Milosz Krajewski Copyright (c) 2016-2017, Matthieu Darbois +Copyright (c) The Internet Society (2003) Copyright (c) .NET Foundation Contributors -Copyright (c) The Internet Society (2003). Copyright (c) .NET Foundation and Contributors Copyright (c) 2019 Microsoft Corporation, Daan Leijen Copyright (c) 2011 Novell, Inc (http://www.novell.com) Copyright (c) 1995-2017 Jean-loup Gailly and Mark Adler Copyright (c) 2015 Xamarin, Inc (http://www.xamarin.com) -Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors. +Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors Copyright (c) 2014 Ryan Juckett http://www.ryanjuckett.com Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc. -Copyright (c) 2015 THL A29 Limited, a Tencent company, and Milo Yip. -Copyright (c) YEAR W3C(r) (MIT, ERCIM, Keio, Beihang). Disclaimers THIS WORK IS PROVIDED AS -Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 The Regents of the University of California. -Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. & Digital Equipment Corporation, Maynard, Mass. +Copyright (c) YEAR W3C(r) (MIT, ERCIM, Keio, Beihang). Disclaimers +Copyright (c) 2015 THL A29 Limited, a Tencent company, and Milo Yip +Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 The Regents of the University of California +Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. & Digital Equipment Corporation, Maynard, Mass Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. & Digital Equipment Corporation, Maynard, Mass. To The MIT License (MIT) @@ -2491,76 +2421,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ---------------------------------------------------------- - ---------------------------------------------------------- - -System.Management 6.0.0 - MIT - - -(c) Microsoft Corporation. -Copyright (c) Andrew Arnott -Copyright 2018 Daniel Lemire -Copyright 2012 the V8 project -Copyright (c) .NET Foundation. -Copyright (c) 2011, Google Inc. -Copyright (c) 1998 Microsoft. To -(c) 1997-2005 Sean Eron Anderson. -Copyright (c) 2017 Yoshifumi Kawai -Copyright (c) Microsoft Corporation -Copyright (c) 2007 James Newton-King -Copyright (c) 2012-2014, Yann Collet -Copyright (c) 2013-2017, Alfred Klomp -Copyright (c) 2015-2017, Wojciech Mula -Copyright (c) 2005-2007, Nick Galbreath -Copyright (c) 2018 Alexander Chermyanin -Portions (c) International Organization -Copyright (c) 2015 The Chromium Authors. -Copyright (c) The Internet Society 1997. -Copyright (c) 2004-2006 Intel Corporation -Copyright (c) 2013-2017, Milosz Krajewski -Copyright (c) 2016-2017, Matthieu Darbois -Copyright (c) .NET Foundation Contributors -Copyright (c) The Internet Society (2003). -Copyright (c) .NET Foundation and Contributors -Copyright (c) 2019 Microsoft Corporation, Daan Leijen -Copyright (c) 2011 Novell, Inc (http://www.novell.com) -Copyright (c) 1995-2017 Jean-loup Gailly and Mark Adler -Copyright (c) 2015 Xamarin, Inc (http://www.xamarin.com) -Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors. -Copyright (c) 2014 Ryan Juckett http://www.ryanjuckett.com -Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc. -Copyright (c) 2015 THL A29 Limited, a Tencent company, and Milo Yip. -Copyright (c) YEAR W3C(r) (MIT, ERCIM, Keio, Beihang). Disclaimers THIS WORK IS PROVIDED AS -Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 The Regents of the University of California. -Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. & Digital Equipment Corporation, Maynard, Mass. -Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. & Digital Equipment Corporation, Maynard, Mass. To - -The MIT License (MIT) - -Copyright (c) .NET Foundation and Contributors - -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - - --------------------------------------------------------- --------------------------------------------------------- @@ -3130,7 +2990,7 @@ SOFTWARE. --------------------------------------------------------- -System.Security.Cryptography.Pkcs 6.0.1 - MIT +System.Security.Cryptography.Pkcs 6.0.2 - MIT (c) Microsoft Corporation From 395b941071f27bb95c27cf75b257f2b91df0c91f Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Wed, 12 Apr 2023 22:14:33 +0000 Subject: [PATCH 17/18] Merged PR 25324: Update the changelog for v7.2.11 release Update the changelog for v7.2.11 release --- CHANGELOG/7.2.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/CHANGELOG/7.2.md b/CHANGELOG/7.2.md index 25abb99af8e..fe011299a62 100644 --- a/CHANGELOG/7.2.md +++ b/CHANGELOG/7.2.md @@ -1,5 +1,40 @@ # 7.2 Changelog +## [7.2.11] - 2023-04-12 + +### Build and Packaging Improvements + +
+ + + +

Bump .NET version to 6.0.16

+ +
+ +
    +
  • Update ThirdPartyNotices.txt
  • +
  • Update cgmanifest.json
  • +
  • Fix the template that creates nuget package
  • +
  • Update the wix file
  • +
  • Update .NET SDK to 6.0.408
  • +
  • Fix the build script and signing template
  • +
  • Fix stage dependencies and typo in release build (#19353)
  • +
  • Fix issues in release build and release pipeline (#19338)
  • +
  • Restructure the package build to simplify signing and packaging stages (#19321)
  • +
  • Skip VT100 tests on Windows Server 2012R2 as console does not support it (#19413)
  • +
  • Improve package management acceptance tests by not going to the gallery (#19412)
  • +
  • Test fixes for stabilizing tests (#19068)
  • +
  • Add stage for symbols job in Release build (#18937)
  • +
  • Use reference assemblies generated by dotnet (#19302)
  • +
  • Add URL for all distributions (#19159)
  • +
  • Update release pipeline to use Approvals and automate some manual tasks (#17837)
  • +
+ +
+ +[7.2.11]: https://github.com/PowerShell/PowerShell/compare/v7.2.10...v7.2.11 + ## [7.2.10] - 2023-02-23 ### Build and Packaging Improvements From 252ba19ba6fbdc4a8f45113e0ed28e3cfdefabf2 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Thu, 13 Apr 2023 17:40:25 +0000 Subject: [PATCH 18/18] Merged PR 25348: Fix the template that creates GitHub draft release Fix the template that creates GitHub draft release --- .../templates/release-CreateGitHubDraft.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/releaseBuild/azureDevOps/templates/release-CreateGitHubDraft.yml b/tools/releaseBuild/azureDevOps/templates/release-CreateGitHubDraft.yml index 0c61ac47219..dc7cf126630 100644 --- a/tools/releaseBuild/azureDevOps/templates/release-CreateGitHubDraft.yml +++ b/tools/releaseBuild/azureDevOps/templates/release-CreateGitHubDraft.yml @@ -66,17 +66,17 @@ steps: "preview.md" } else { - $semanticVersion.Major + "." + $semanticVersion.Minor + ".md" + $semanticVersion.Major.ToString() + "." + $semanticVersion.Minor.ToString() + ".md" } - $filePath = $env:BUILD_SOURCESDIRECTORY/CHANGELOG/$fileName + $filePath = "$env:BUILD_SOURCESDIRECTORY/CHANGELOG/$fileName" Write-Verbose -Verbose "Selected Log file: $filePath" if (-not (Test-Path $filePath)) { throw "$filePath not found" } - $changelog = Get-Content -Raw -Path $filePath + $changelog = Get-Content -Path $filePath $startPattern = "^## \[" + ([regex]::Escape($releaseVersion)) + "\]" $endPattern = "^## \[{0}\.{1}\.{2}*" -f $semanticVersion.Major, $semanticVersion.Minor, $semanticVersion.Patch @@ -85,9 +85,9 @@ steps: if ($_ -match $startPattern) { $outputLine = $true } elseif ($_ -match $endPattern) { $outputLine = $false } if ($outputLine) { $_} - } + } | Out-String Write-Verbose -Verbose "Selected content: `n$clContent" - Publish-ReleaseDraft -Tag '$(ReleaseTag)' -Name '$(ReleaseTag) Release of PowerShell' -Description $clContent -User PowerShell -Repository PowerShell -PackageFolder $(System.ArtifactsDirectory) -Token $(GitHubReleasePat) + Publish-ReleaseDraft -Tag '$(ReleaseTag)' -Name '$(ReleaseTag) Release of PowerShell' -Description $clContent -User PowerShell -Repository PowerShell -PackageFolder $(PackagesRoot) -Token $(GitHubReleasePat) displayName: Publish Release Draft