msbuild/.exp-insertions.yml

237 строки
9.6 KiB
YAML

# Pipeline creates experimental msbuild insertions.
trigger: none # Prevents this pipeline from triggering on check-ins
pr: none # don't run this on PR as well
parameters:
# Dotnet installer channel from which to take the latest dotnet bits.
- name: DotnetInstallerChannel
displayName: Dotnet installer channel
type: string
default: 'none'
# VS version for which to take the latest Retail MSBuild bits.
- name: VSVersionName
displayName: VS Version
type: string
default: 'none'
# Branch from the MSBuild Build CI pipeline. Default: main
# Top run for the branch would be used to create an experimental insertion.
- name: MSBuildBranch
displayName: MSBuild Branch
type: string
default: 'refs/heads/main'
# BuildID from the MSBuild Build CI pipeline. Overrides the choice of MSBuildBranch parameter
- name: MSBuildBuildID
displayName: MSBuild CI Run Override
type: string
default: 'default'
variables:
- name: _MsBuildCiPipelineId
value: 9434
- name: _MSBuildConfigFilePathRequestURL
value: 'https://dev.azure.com/cloudbuild/CloudBuild/_apis/git/repositories/CloudBuildConfig/items?versionDescriptor.version=main&path=config/batmon/Q-Prod-Co3/Coordinator/ToolsReleaseConfig-GeneralPublic.json&api-version=5.0'
- name: VSVersion
value: ${{parameters.VSVersionName}}
pool:
vmImage: windows-latest
jobs:
- job: CreateExpDotnet
displayName: Create Experimental Dotnet
condition: ne('${{ parameters.DotnetInstallerChannel }}', 'none')
steps:
- powershell: |
mkdir '$(System.ArtifactsDirectory)/installer'
$dotnetChannel = '${{parameters.DotnetInstallerChannel}}'
$sdks = "dotnet-sdk-win-x64.zip", "dotnet-sdk-linux-x64.tar.gz"
foreach ($sdk in $sdks)
{
Write-Host "Downloading dotnet $sdk from channel $dotnetChannel"
Invoke-WebRequest `
-Uri "https://aka.ms/dotnet/$dotnetChannel/daily/$sdk" `
-OutFile "$(System.ArtifactsDirectory)/installer/$sdk"
}
mkdir '$(Pipeline.Workspace)/artifacts'
displayName: Download latest dotnet sdks
- task: DownloadBuildArtifacts@1
inputs:
buildType: specific
project: DevDiv
pipeline: $(_MsBuildCiPipelineId)
${{ if eq(parameters.MSBuildBuildID, 'default') }}:
buildVersionToDownload: latestFromBranch
branchName: '${{parameters.MSBuildBranch}}'
${{ else }}:
buildVersionToDownload: specific
buildId: ${{parameters.MSBuildBuildID}}
artifactName: bin
itemPattern: 'MSBuild.Bootstrap/**'
downloadPath: '$(System.ArtifactsDirectory)/msbuild/artifacts/bin'
displayName: Download msbuild artifacts
- powershell: |
$sdk = "dotnet-sdk-win-x64"
Write-Host "Extracting $(System.ArtifactsDirectory)/installer/$sdk.zip"
Expand-Archive "$(System.ArtifactsDirectory)/installer/$sdk.zip" -DestinationPath "$(Pipeline.Workspace)/exp-dotnet/$sdk"
$dotnetDirectory = Get-ChildItem -Directory -Path "$(Pipeline.Workspace)/exp-dotnet/$sdk/sdk"
$dotnetVersion = $dotnetDirectory.Name
Write-Host "Detected dotnet version: $dotnetVersion"
Write-Host "Updating MSBuild dlls."
$(Build.SourcesDirectory)/scripts/Deploy-MSBuild.ps1 `
-destination "$(Pipeline.Workspace)/exp-dotnet/$sdk/sdk/$dotnetVersion" `
-binDirectory "$(System.ArtifactsDirectory)/msbuild/artifacts/bin" `
-configuration Release `
-makeBackup $false
Write-Host "Compressing dotnet sdk files"
Get-ChildItem -Path "$(Pipeline.Workspace)/exp-dotnet/$sdk" | Compress-Archive -DestinationPath "$(Pipeline.Workspace)/artifacts/$sdk.zip"
displayName: Dogfood msbuild dlls to dotnet sdk win-x64
- powershell: |
$sdk = "dotnet-sdk-linux-x64"
mkdir "$(Pipeline.Workspace)/exp-dotnet/$sdk"
Write-Host "Extracting $(System.ArtifactsDirectory)/installer/$sdk.tar.gz"
tar -xzvf "$(System.ArtifactsDirectory)/installer/$sdk.tar.gz" -C "$(Pipeline.Workspace)/exp-dotnet/$sdk"
$dotnetDirectory = Get-ChildItem -Directory -Path $(Pipeline.Workspace)/exp-dotnet/$sdk/sdk
$dotnetVersion = $dotnetDirectory.Name
Write-Host "Detected dotnet version: $dotnetVersion"
Write-Host "Updating MSBuild dlls."
$(Build.SourcesDirectory)/scripts/Deploy-MSBuild.ps1 `
-destination "$(Pipeline.Workspace)/exp-dotnet/$sdk/sdk/$dotnetVersion" `
-binDirectory "$(System.ArtifactsDirectory)/msbuild/artifacts/bin" `
-configuration Release `
-makeBackup $false
Write-Host "Compressing dotnet sdk files"
tar -czvf "$(Pipeline.Workspace)/artifacts/$sdk.tar.gz" -C "$(Pipeline.Workspace)/exp-dotnet/$sdk" .
displayName: Dogfood msbuild dlls to dotnet sdk linux-x64
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Pipeline.Workspace)/artifacts'
artifactName: ExperimentalDotnet
parallel: true
condition: always()
displayName: Publish crank assests artifacts
- job: CreateExpMSBuild
displayName: "Create Experimental MSBuild"
condition: ne('${{ parameters.VSVersionName }}', 'none')
steps:
- powershell: |
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("PAT:$env:ACCESSTOKEN"))
$headers = @{ Authorization = "Basic $token" };
$response = Invoke-RestMethod -Uri "$(_MSBuildConfigFilePathRequestURL)" -Headers $headers -Method Get
$MSBuildDropPath = $response.Tools.MSBuild.Locations
Write-Host "##vso[task.setvariable variable=MSBuildDropPath]$MSBuildDropPath"
Write-Host "MSBuild Drop Path directory: $MSBuildDropPath"
displayName: Get Retail MSBuild Drop Path
env:
ACCESSTOKEN: $(cloudbuild-token)
- task: NuGetToolInstaller@1
displayName: 'Install NuGet.exe'
- task: NuGetCommand@2
displayName: Restore internal tools
inputs:
command: restore
feedsToUse: config
restoreSolution: '$(Build.SourcesDirectory)\eng\common\internal\Tools.csproj'
nugetConfigPath: '$(Build.SourcesDirectory)\NuGet.config'
restoreDirectory: '$(Build.SourcesDirectory)\.packages'
# https://eng.ms/docs/cloud-ai-platform/devdiv/one-engineering-system-1es/1es-docs/1es-security-configuration/configuration-guides/pat-burndown-guidance#authentication-from-pipelines
# Requires Azure client 2.x
- task: AzureCLI@2
displayName: 'Set AzDO.DotnetPerfStarToken'
enabled: true
inputs:
azureSubscription: 'dotnet-perfstar at app.vssps.visualstudio.com' # Azure DevOps service connection
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: |
# '499b84ac-1321-427f-aa17-267ca6975798' for Azure DevOps
$token = az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv
Write-Host "Setting AzDO.DotnetPerfStarToken"
Write-Host "##vso[task.setvariable variable=AzDO.DotnetPerfStarToken]${token}"
- powershell: |
mkdir "$(Pipeline.Workspace)/artifacts"
$dropAppDirectory = Get-ChildItem -Directory -Path "$(Build.SourcesDirectory)/.packages/drop.app"
$dropAppVersion = $dropAppDirectory.Name
Write-Host "Detected drop.exe version: $dropAppVersion"
$dropExePath = "$(Build.SourcesDirectory)/.packages/drop.app/$dropAppVersion/lib/net45/drop.exe"
Write-Host "Detected drop.exe path: $dropExePath"
Write-Host "Downloading VS msbuild"
$patAuthEnvVar = "patVariable"
& "$dropExePath" get --patAuthEnvVar $patAuthEnvVar -u "$(MSBuildDropPath)\$(VSVersion)" -d "$(System.ArtifactsDirectory)/VSMSBuildDrop"
Write-Host "Download of VS msbuild finished"
Write-Host "Copying VS msbuild to $(Pipeline.Workspace)/VSMSBuild"
Copy-Item -Path "$(System.ArtifactsDirectory)/VSMSBuildDrop/*" -Destination "$(Pipeline.Workspace)/VSMSBuild" -Recurse
Write-Host "Copy of VS msbuild finished"
displayName: Download msbuild vs drop
env:
patVariable: $(AzDO.DotnetPerfStarToken)
- task: DownloadBuildArtifacts@1
inputs:
buildType: specific
project: DevDiv
pipeline: $(_MsBuildCiPipelineId)
${{ if eq(parameters.MSBuildBuildID, 'default') }}:
buildVersionToDownload: latestFromBranch
branchName: '${{parameters.MSBuildBranch}}'
${{ else }}:
buildVersionToDownload: specific
buildId: ${{parameters.MSBuildBuildID}}
artifactName: bin
itemPattern: |
MSBuild.Bootstrap/*/net472/**
Microsoft.Build.Conversion/*/net472/Microsoft.Build.Conversion.Core.dll
Microsoft.Build.Engine/*/net472/Microsoft.Build.Engine.dll
MSBuildTaskHost/**/MSBuildTaskHost.exe
MSBuildTaskHost/**/MSBuildTaskHost.pdb
MSBuild/*/*/net472/MSBuild.exe*
downloadPath: '$(System.ArtifactsDirectory)/msbuild/artifacts/bin'
displayName: Download msbuild artifacts
- powershell: |
Write-Host "Updating MSBuild dlls."
$(Build.SourcesDirectory)/scripts/Deploy-MSBuild.ps1 `
-destination "$(Pipeline.Workspace)/VSMSBuild/$(VSVersion)/MSBuild/Current/Bin" `
-binDirectory "$(System.ArtifactsDirectory)/msbuild/artifacts/bin" `
-configuration Release `
-makeBackup $false
ls "$(Pipeline.Workspace)/VSMSBuild/$(VSVersion)"
Write-Host "Compressing msbuild files"
Get-ChildItem -Path "$(Pipeline.Workspace)/VSMSBuild/$(VSVersion)" | Compress-Archive -DestinationPath "$(Pipeline.Workspace)/artifacts/MSBuild.zip"
displayName: Dogfood msbuild dlls
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Pipeline.Workspace)/artifacts'
artifactName: ExperimentalMSBuild
parallel: true
condition: always()
displayName: Publish crank assests artifacts