From 94d623169a61453ac9686b1596dcd71673ac4224 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Wed, 3 Apr 2024 15:06:04 -0700 Subject: [PATCH] Multiple fixes in official build pipeline (#21408) --- .config/tsaoptions.json | 8 ++++++- ...werShell-Coordinated_Packages-Official.yml | 13 ++--------- .../templates/insert-nuget-config-azfeed.yml | 4 ++-- .pipelines/templates/linux.yml | 12 +++++++--- .pipelines/templates/mac.yml | 23 +++++++++++-------- .pipelines/templates/windows-hosted-build.yml | 5 ++++ .../PSVersionInfoGenerator.csproj | 2 +- 7 files changed, 40 insertions(+), 27 deletions(-) diff --git a/.config/tsaoptions.json b/.config/tsaoptions.json index 90d4db3675..bd2a6a0098 100644 --- a/.config/tsaoptions.json +++ b/.config/tsaoptions.json @@ -1,5 +1,11 @@ { "instanceUrl": "https://msazure.visualstudio.com", "projectName": "One", - "areaPath": "One\\MGMT\\Compute\\Powershell\\Powershell\\PowerShell Core" + "areaPath": "One\\MGMT\\Compute\\Powershell\\Powershell\\PowerShell Core", + "notificationAliases": [ + "adityap@microsoft.com", + "dongbow@microsoft.com", + "pmeinecke@microsoft.com", + "tplunk@microsoft.com" + ] } diff --git a/.pipelines/PowerShell-Coordinated_Packages-Official.yml b/.pipelines/PowerShell-Coordinated_Packages-Official.yml index 432a627b0d..adc614f328 100644 --- a/.pipelines/PowerShell-Coordinated_Packages-Official.yml +++ b/.pipelines/PowerShell-Coordinated_Packages-Official.yml @@ -1,14 +1,5 @@ name: UnifiedPackageBuild-$(Build.BuildId) -trigger: - branches: - include: - - master - - release* -pr: - branches: - include: - - master - - release* +trigger: none parameters: - name: ForceAzureBlobDelete @@ -194,7 +185,7 @@ extends: parameters: Architecture: x64 BuildConfiguration: minSize - JobName: build_windows_x64_minSize + JobName: build_windows_x64_minSize_release - template: /.pipelines/templates/windows-hosted-build.yml@self parameters: Architecture: x86 diff --git a/.pipelines/templates/insert-nuget-config-azfeed.yml b/.pipelines/templates/insert-nuget-config-azfeed.yml index 2279c4839a..19884080e4 100644 --- a/.pipelines/templates/insert-nuget-config-azfeed.yml +++ b/.pipelines/templates/insert-nuget-config-azfeed.yml @@ -5,7 +5,7 @@ steps: - pwsh: | $configPath = "${env:NugetConfigDir}/nuget.config" Import-Module ${{ parameters.repoRoot }}/build.psm1 -Force - New-NugetConfigFile -NugetFeedUrl $(AzDevOpsFeed) -UserName $(AzDevOpsFeedUserName) -ClearTextPAT $(AzDevOpsFeedPAT2) -FeedName AzDevOpsFeed -Destination "${env:NugetConfigDir}" + New-NugetConfigFile -NugetFeedUrl $(PowerShellCore_PublicPackages) -UserName $(AzDevOpsFeedUserName) -ClearTextPAT $(AzDevOpsFeedUserName) -FeedName AzDevOpsFeed -Destination "${env:NugetConfigDir}" if(-not (Test-Path $configPath)) { throw "nuget.config is not created" @@ -20,7 +20,7 @@ steps: - pwsh: | $configPath = "${env:NugetConfigDir}/nuget.config" Import-Module ${{ parameters.repoRoot }}/build.psm1 -Force - New-NugetConfigFile -NugetFeedUrl $(PSInternalNugetFeed) -UserName $(PSInternalNugetFeedUserName) -ClearTextPAT $(PSInternalNugetFeedPAT) -FeedName AzDevOpsFeed -Destination "${env:NugetConfigDir}" + New-NugetConfigFile -NugetFeedUrl $(PowerShellCore_PublicPackages) -UserName $(AzDevOpsFeedUserName) -ClearTextPAT $(AzDevOpsFeedUserName) -FeedName AzDevOpsFeed -Destination "${env:NugetConfigDir}" if(-not (Test-Path $configPath)) { throw "nuget.config is not created" diff --git a/.pipelines/templates/linux.yml b/.pipelines/templates/linux.yml index 134d581833..0ab4f54e4f 100644 --- a/.pipelines/templates/linux.yml +++ b/.pipelines/templates/linux.yml @@ -27,7 +27,7 @@ jobs: value: $(Build.SourcesDirectory)\PowerShell\.config\tsaoptions.json - name: ob_sdl_credscan_suppressionsFile value: $(Build.SourcesDirectory)\PowerShell\.config\suppress.json - - name: BuildConfiguration + - name: BUILDCONFIGURATION value: ${{ parameters.BuildConfiguration }} - name: Runtime value: ${{ parameters.Runtime }} @@ -66,7 +66,8 @@ jobs: $runtime = $env:RUNTIME $params = @{} - if ($env:BuildConfiguration -eq 'minSize') { + if ($env:BUILDCONFIGURATION -eq 'minSize') { + Write-Verbose -Message "Building for minimal size" $params['ForMinimalSize'] = $true } @@ -78,6 +79,11 @@ jobs: $null = New-Item -ItemType Directory -Path $buildWithSymbolsPath -Force -Verbose Start-PSBuild -Runtime $runtime -Configuration Release -Output $buildWithSymbolsPath @params -Clean -PSModuleRestore + $outputPath = Join-Path '$(ob_outputDirectory)' 'psoptions' + $null = New-Item -ItemType Directory -Path $outputPath -Force + $psOptPath = "$outputPath/psoptions.json" + Save-PSOptions -PSOptionsPath $psOptPath + Write-Verbose -Verbose "Verifying pdbs exist in build folder" $pdbs = Get-ChildItem -Path $buildWithSymbolsPath -Recurse -Filter *.pdb if ($pdbs.Count -eq 0) { @@ -90,7 +96,7 @@ jobs: } } - Write-Verbose -Verbose "Completed building PowerShell for '$env:BuildConfiguration' configuration" + Write-Verbose -Verbose "Completed building PowerShell for '$env:BUILDCONFIGURATION' configuration" displayName: 'Build Linux - $(Runtime)' env: __DOTNET_RUNTIME_FEED_KEY: $(RUNTIME_SOURCEFEED_KEY) diff --git a/.pipelines/templates/mac.yml b/.pipelines/templates/mac.yml index 7542ffad4c..4b46cfff46 100644 --- a/.pipelines/templates/mac.yml +++ b/.pipelines/templates/mac.yml @@ -54,7 +54,17 @@ jobs: $env:AzDevOpsFeedPAT2 = '$(AzDevOpsFeedPAT2)' # Add -SkipReleaseChecks as a mitigation to unblock release. # macos-10.15 does not allow creating a folder under root. Hence, moving the folder. - $(Build.SourcesDirectory)/tools/releaseBuild/macOS/PowerShellPackageVsts.ps1 -ReleaseTag $(ReleaseTagVar) -Destination $(System.ArtifactsDirectory) -Symbols -location $(PowerShellRoot) -Build -ArtifactName macosBinResults -Runtime 'osx-${{ parameters.buildArchitecture }}' -SkipReleaseChecks + + Import-Module ./build.psm1 -Force + Start-PSBuild -Runtime 'osx-${{ parameters.buildArchitecture }}' -Configuration Release -PSModuleRestore -Clean -Output $(OB_OUTPUTDIRECTORY) + $artifactName = "macosBinResults-${{ parameters.buildArchitecture }}" + + $psOptPath = "$(OB_OUTPUTDIRECTORY)/psoptions.json" + Save-PSOptions -PSOptionsPath $psOptPath + + # Since we are using custom pool for macOS, we need to use artifact.upload to publish the artifacts + Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName]$(OB_OUTPUTDIRECTORY)" + $env:AzDevOpsFeedPAT2 = $null displayName: 'Build' env: @@ -84,7 +94,7 @@ jobs: - name: ob_sdl_codeql_compiled_enabled value: false - name: ob_sdl_sbom_packageName - value: 'Microsoft.Powershell.Windows.${{parameters.buildArchitecture}}' + value: 'Microsoft.Powershell.MacOS.${{parameters.buildArchitecture}}' steps: - checkout: self @@ -100,7 +110,7 @@ jobs: - task: DownloadPipelineArtifact@2 inputs: - artifact: 'macosBinResults' + artifact: 'macosBinResults-$(BuildArchitecture)' path: '$(Pipeline.Workspace)\Symbols' displayName: Download build @@ -115,12 +125,7 @@ jobs: Write-Host "sending.. vso[task.setvariable variable=Runtime]$runtime" Write-Host "##vso[task.setvariable variable=Runtime]$runtime" - $zipPath = Get-Item '$(Pipeline.Workspace)\Symbols\*symbol*${{ parameters.buildArchitecture }}*.zip' -Verbose - Write-Verbose -Verbose "Zip Path: $zipPath" - - $expandedFolder = $zipPath.BaseName - Expand-Archive -Path $zipPath -Destination "$(Pipeline.Workspace)\$expandedFolder" -Force - $rootPath = "$(Pipeline.Workspace)\$expandedFolder" + $rootPath = "$(Pipeline.Workspace)\Symbols" Write-Verbose -Verbose "Setting vso[task.setvariable variable=DropRootPath]$rootPath" Write-Host "##vso[task.setvariable variable=DropRootPath]$rootPath" displayName: Expand symbols zip diff --git a/.pipelines/templates/windows-hosted-build.yml b/.pipelines/templates/windows-hosted-build.yml index 1f100783a2..15ca7e9c58 100644 --- a/.pipelines/templates/windows-hosted-build.yml +++ b/.pipelines/templates/windows-hosted-build.yml @@ -89,6 +89,11 @@ jobs: $null = New-Item -ItemType Directory -Path $buildWithSymbolsPath -Force -Verbose Start-PSBuild -Runtime $runtime -Configuration Release -Output $buildWithSymbolsPath -Clean -PSModuleRestore @params + $outputPath = Join-Path '$(ob_outputDirectory)' 'psoptions' + $null = New-Item -ItemType Directory -Path $outputPath -Force + $psOptPath = "$outputPath/psoptions.json" + Save-PSOptions -PSOptionsPath $psOptPath + Write-Verbose -Verbose "Verifying pdbs exist in build folder" $pdbs = Get-ChildItem -Path $buildWithSymbolsPath -Recurse -Filter *.pdb if ($pdbs.Count -eq 0) { diff --git a/src/System.Management.Automation/SourceGenerators/PSVersionInfoGenerator/PSVersionInfoGenerator.csproj b/src/System.Management.Automation/SourceGenerators/PSVersionInfoGenerator/PSVersionInfoGenerator.csproj index 3b9f63d448..85c7127d7f 100644 --- a/src/System.Management.Automation/SourceGenerators/PSVersionInfoGenerator/PSVersionInfoGenerator.csproj +++ b/src/System.Management.Automation/SourceGenerators/PSVersionInfoGenerator/PSVersionInfoGenerator.csproj @@ -15,6 +15,6 @@ - +