|
| 1 | +# Create an experimental VS insertion auto-triggered from exp/* branches to validate changes before merging to main |
| 2 | +trigger: none |
| 3 | +name: $(Date:yyyyMMdd).$(Rev:r) |
| 4 | + |
| 5 | +resources: |
| 6 | + pipelines: |
| 7 | + - pipeline: 'MSBuild' |
| 8 | + project: 'DevDiv' |
| 9 | + source: 'MSBuild' |
| 10 | + trigger: |
| 11 | + branches: |
| 12 | + include: |
| 13 | + - exp/* |
| 14 | + repositories: |
| 15 | + - repository: 1ESPipelineTemplates |
| 16 | + type: git |
| 17 | + name: 1ESPipelineTemplates/1ESPipelineTemplates |
| 18 | + ref: refs/tags/release |
| 19 | + |
| 20 | +parameters: |
| 21 | + - name: TargetBranch |
| 22 | + type: string |
| 23 | + default: main |
| 24 | + displayName: 'Insertion Target Branch (select for manual insertion)' |
| 25 | + values: |
| 26 | + - main |
| 27 | + - rel/d17.14 |
| 28 | + - rel/d17.13 |
| 29 | + - rel/d17.12 |
| 30 | + - rel/d17.11 |
| 31 | + - rel/d17.10 |
| 32 | + - rel/d17.8 |
| 33 | + - rel/d17.6 |
| 34 | + - rel/d17.3 |
| 35 | + - rel/d17.0 |
| 36 | + |
| 37 | +variables: |
| 38 | + - name: TeamName |
| 39 | + value: msbuild |
| 40 | + - name: TeamEmail |
| 41 | + |
| 42 | + - name: MSBuild_CI_BuildNumber |
| 43 | + value: $(resources.pipeline.MSBuild.runName) |
| 44 | + - name: MSBuild_CI_SourceVersion |
| 45 | + value: $(resources.pipeline.MSBuild.sourceCommit) |
| 46 | + - name: ArtifactPackagesPath |
| 47 | + value: $(Build.ArtifactStagingDirectory)/PackageArtifacts |
| 48 | + |
| 49 | + - name: MSBuildPackagePattern |
| 50 | + value: '$(ArtifactPackagesPath)/Microsoft.Build.*.nupkg' |
| 51 | + - name: StringToolsPackagePattern |
| 52 | + value: '$(ArtifactPackagesPath)/Microsoft.NET.StringTools*.nupkg' |
| 53 | + - name: ExternalAPIsPackagePattern |
| 54 | + value: '$(ArtifactPackagesPath)/VS.ExternalAPIs.*.nupkg' |
| 55 | + |
| 56 | +extends: |
| 57 | + template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates |
| 58 | + parameters: |
| 59 | + pool: |
| 60 | + name: VSEngSS-MicroBuild2022-1ES |
| 61 | + stages: |
| 62 | + - stage: VSInsertion |
| 63 | + displayName: VS insertion |
| 64 | + variables: |
| 65 | + VSDropPath: https://vsdrop.corp.microsoft.com/file/v1/Products/DevDiv/DotNet-msbuild-Trusted/$(SourceBranchName)/$(MSBuild_CI_BuildNumber) |
| 66 | + VSManVersionSuffix: $(MSBuild_ExtApisPackageVersion)+$(MSBuild_CI_SourceVersion) |
| 67 | + StandardVSManPath: Microsoft.Build.vsman{$(VSManVersionSuffix)}=$(VSDropPath);Microsoft.Build.vsman |
| 68 | + Arm64VSManPath: Microsoft.Build.Arm64.vsman{$(VSManVersionSuffix)}=$(VSDropPath);Microsoft.Build.Arm64.vsman |
| 69 | + UnGACVSManPath: Microsoft.Build.UnGAC.vsman=$(VSDropPath);Microsoft.Build.UnGAC.vsman |
| 70 | + InsertJsonValues: $(StandardVSManPath),$(Arm64VSManPath),$(UnGACVSManPath) |
| 71 | + InsertConfigValues: VS.ExternalAPIs.MSBuild=$(MSBuild_ExtApisPackageVersion) |
| 72 | + InsertCustomScriptExecutionCommand: $(Pipeline.Workspace)\xsd\Update-MSBuildXsds.ps1 |
| 73 | + InsertDescription: Insert MSBuild $(MSBuild_CI_BuildNumber) from the branch $(SourceBranchName) at commit $(MSBuild_CI_SourceVersion). Corresponding package version is $(MSBuild_ExtApisPackageVersion) |
| 74 | + InsertPayloadName: '[Experimental] [Skip-SymbolCheck] MSBuild $(SourceBranchName) $(MSBuild_ExtApisPackageVersion)' |
| 75 | + jobs: |
| 76 | + - job: PushPackagesAndInsert |
| 77 | + displayName: Push Packages and Insert VS payload |
| 78 | + condition: succeeded() |
| 79 | + timeoutInMinutes: 0 |
| 80 | + templateContext: |
| 81 | + inputs: |
| 82 | + - input: pipelineArtifact |
| 83 | + pipeline: 'MSBuild' |
| 84 | + artifactName: 'xsd' |
| 85 | + targetPath: '$(Pipeline.Workspace)/xsd' |
| 86 | + - input: pipelineArtifact |
| 87 | + pipeline: 'MSBuild' |
| 88 | + artifactName: 'PackageArtifacts' |
| 89 | + targetPath: '$(Build.ArtifactStagingDirectory)/PackageArtifacts' |
| 90 | + # the CI build creates a sourcebuild intermediate package that is not signed, remove it to avoid warning from Guardian |
| 91 | + itemPattern: | |
| 92 | + ** |
| 93 | + !**/Microsoft.SourceBuild.Intermediate*.nupkg |
| 94 | + steps: |
| 95 | + - task: Powershell@2 |
| 96 | + name: SetSourceBranch |
| 97 | + displayName: Set source branch name |
| 98 | + inputs: |
| 99 | + targetType: inline |
| 100 | + script: | |
| 101 | + # Extract the last section after the last '/' |
| 102 | + $fullBranch = "$(resources.pipeline.MSBuild.sourceBranch)" |
| 103 | + $branchSegments = $fullBranch -split '/' |
| 104 | + $branch = $branchSegments[-1] |
| 105 | + Write-Host "Setting drops branch to '$branch'" |
| 106 | + Write-Host "##vso[task.setvariable variable=SourceBranchName]$branch" |
| 107 | +
|
| 108 | + - task: Powershell@2 |
| 109 | + name: DetermineTargetBranch |
| 110 | + displayName: Determine target branch |
| 111 | + inputs: |
| 112 | + targetType: inline |
| 113 | + script: | |
| 114 | + # Extract VS version from branch name if it follows exp/vsXX.Y-somename pattern |
| 115 | + $fullBranch = "$(resources.pipeline.MSBuild.sourceBranch)" |
| 116 | + $parameterTargetBranch = "${{ parameters.TargetBranch }}" |
| 117 | + $detectedTarget = "main" # Default target branch |
| 118 | +
|
| 119 | + # Try to match the pattern with regex |
| 120 | + if ($fullBranch -match "exp/vs(\d+)\.(\d+).*") { |
| 121 | + $major = $matches[1] |
| 122 | + $minor = $matches[2] |
| 123 | + $targetBranch = "rel/d$major.$minor" |
| 124 | + Write-Host "Detected version pattern in branch: $major.$minor" |
| 125 | + Write-Host "Setting target branch to $targetBranch" |
| 126 | + $detectedTarget = $targetBranch |
| 127 | + } else { |
| 128 | + Write-Host "No version pattern detected in branch, using default target: main" |
| 129 | + } |
| 130 | +
|
| 131 | + # Determine which target branch to use based on build reason |
| 132 | + $finalTargetBranch = $parameterTargetBranch |
| 133 | + if ("$(Build.Reason)" -eq "ResourceTrigger" -or "$(Build.Reason)" -eq "PipelineCompletedTrigger") { |
| 134 | + Write-Host "Build was triggered automatically, using detected target branch: $detectedTarget" |
| 135 | + $finalTargetBranch = $detectedTarget |
| 136 | + } else { |
| 137 | + Write-Host "Build was triggered manually, using parameter target branch: $parameterTargetBranch" |
| 138 | + } |
| 139 | +
|
| 140 | + Write-Host "##vso[task.setvariable variable=FinalTargetBranch]$finalTargetBranch" |
| 141 | +
|
| 142 | + - task: Powershell@2 |
| 143 | + name: PwshMungeExternalAPIsPkgVersion |
| 144 | + displayName: Munge ExternalAPIs package version |
| 145 | + inputs: |
| 146 | + targetType: inline |
| 147 | + script: | |
| 148 | + $folder = "$(Build.ArtifactStagingDirectory)/PackageArtifacts/VS.ExternalAPIs.*.nupkg" |
| 149 | + $packageFile = Get-ChildItem -Path $folder -Filter VS.ExternalAPIs.*.nupkg | Select-Object -First 1 |
| 150 | + $packageVersion = $packageFile.BaseName.TrimStart("VS.ExternalAPIs.MSBuild") |
| 151 | + Write-Host "Setting MSBuild_ExtApisPackageVersion to '$packageVersion'" |
| 152 | + Write-Host "##vso[task.setvariable variable=MSBuild_ExtApisPackageVersion]$($packageVersion)" |
| 153 | + $folder = "$(Build.ArtifactStagingDirectory)/PackageArtifacts/Microsoft.NET.StringTools*.nupkg" |
| 154 | + $packageFile = Get-ChildItem -Path $folder -Filter Microsoft.NET.StringTools*.nupkg | Select-Object -First 1 |
| 155 | + $packageVersion = $packageFile.BaseName.TrimStart("Microsoft.NET.StringTools") |
| 156 | + Write-Host "Setting MicrosoftNETStringToolsPackageVersion to '$packageVersion'" |
| 157 | + Write-Host "##vso[task.setvariable variable=MicrosoftNETStringToolsPackageVersion]$($packageVersion)" |
| 158 | + - task: 1ES.PublishNuGet@1 |
| 159 | + displayName: 'Push MSBuild CoreXT packages' |
| 160 | + inputs: |
| 161 | + packageParentPath: '$(Build.ArtifactStagingDirectory)' |
| 162 | + packagesToPush: $(MSBuildPackagePattern);$(StringToolsPackagePattern);$(ExternalAPIsPackagePattern) |
| 163 | + nuGetFeedType: internal |
| 164 | + publishVstsFeed: VS |
| 165 | + allowPackageConflicts: true |
| 166 | + - task: MicroBuildInsertVsPayload@4 |
| 167 | + name: MicroBuildInsertVsPayload_4 |
| 168 | + displayName: Insert VS Payload |
| 169 | + inputs: |
| 170 | + LinkWorkItemsToPR: true |
| 171 | + TeamName: $(TeamName) |
| 172 | + TeamEmail: $(TeamEmail) |
| 173 | + TargetBranch: $(FinalTargetBranch) |
| 174 | + InsertionPayloadName: $(InsertPayloadName) |
| 175 | + PackagePropsValues: VS.ExternalAPIs.MSBuild=$(MSBuild_ExtApisPackageVersion);Microsoft.Build=$(MicrosoftNETStringToolsPackageVersion);Microsoft.Build.Framework=$(MicrosoftNETStringToolsPackageVersion);Microsoft.Build.Tasks.Core=$(MicrosoftNETStringToolsPackageVersion);Microsoft.Build.Utilities.Core=$(MicrosoftNETStringToolsPackageVersion);Microsoft.NET.StringTools=$(MicrosoftNETStringToolsPackageVersion) |
| 176 | + InsertionDescription: $(InsertDescription) |
| 177 | + ComponentJsonValues: $(InsertJsonValues) |
| 178 | + DefaultConfigValues: $(InsertConfigValues) |
| 179 | + InsertionReviewers: MSBuild |
| 180 | + CustomScriptExecutionCommand: $(InsertCustomScriptExecutionCommand) |
| 181 | + InsertionBuildPolicy: Request Perf DDRITs |
0 commit comments