Skip to content

Commit c8ad329

Browse files
committed
update deloyment script
1 parent 3c910ba commit c8ad329

File tree

2 files changed

+142
-7
lines changed

2 files changed

+142
-7
lines changed

.exp-insertions.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Pipeline creates a dotnet with experimental msbuild dlls.
2+
3+
trigger: none # Prevents this pipeline from triggering on check-ins
4+
pr: none # don't run this on PR as well
5+
6+
parameters:
7+
# Dotnet installer channel from where to take the latest dotnet bits.
8+
- name: DotnetInstallerChannel
9+
displayName: Dotnet installer channel
10+
type: string
11+
# Branch from the MSBuild Build CI pipeline. Default: main
12+
# Top run for the branch would be used to create an experimental insertion.
13+
- name: MSBuildBranch
14+
displayName: MSBuild Branch
15+
type: string
16+
default: 'refs/heads/main'
17+
# BuildID from the MSBuild Build CI pipeline. Overrides the choice of MSBuildBranch parameter
18+
- name: MSBuildBuildID
19+
displayName: MSBuild CI Run Override
20+
type: string
21+
default: 'default'
22+
23+
pool:
24+
vmImage: windows-latest
25+
26+
steps:
27+
- powershell: |
28+
mkdir '$(System.ArtifactsDirectory)/installer'
29+
30+
$dotnetChannel = '${{parameters.DotnetInstallerChannel}}'
31+
$sdks = "dotnet-sdk-win-x64.zip", "dotnet-sdk-linux-x64.tar.gz"
32+
33+
foreach ($sdk in $sdks)
34+
{
35+
Write-Host "Downloading dotnet $sdk from channel $dotnetChannel"
36+
Invoke-WebRequest `
37+
-Uri "https://aka.ms/dotnet/$dotnetChannel/daily/$sdk" `
38+
-OutFile "$(System.ArtifactsDirectory)/installer/$sdk"
39+
}
40+
mkdir '$(Pipeline.Workspace)/artifacts'
41+
42+
displayName: Download latest dotnet sdks
43+
44+
# Download latest build artifacts for a branch from MSBuild Build CI
45+
- ${{ if eq(parameters.MSBuildBuildID, 'default') }}:
46+
- task: DownloadBuildArtifacts@1
47+
inputs:
48+
buildType: specific
49+
project: DevDiv
50+
pipeline: 9434 # MSBuild Build CI
51+
buildVersionToDownload: latestFromBranch
52+
branchName: '${{parameters.MSBuildBranch}}'
53+
artifactName: bin
54+
downloadPath: '$(System.ArtifactsDirectory)/msbuild/artifacts/bin'
55+
itemPattern: "MSBuild.Bootstrap/**"
56+
displayName: Download latest msbuild from branch
57+
58+
# Download build artifacts for MSBuild Build CI specific build
59+
- ${{ if ne(parameters.MSBuildBuildID, 'default') }}:
60+
- task: DownloadBuildArtifacts@1
61+
inputs:
62+
buildType: specific
63+
project: DevDiv
64+
pipeline: 9434 # MSBuild Build CI
65+
buildVersionToDownload: specific
66+
buildId: ${{parameters.MSBuildBuildID}}
67+
artifactName: bin
68+
downloadPath: '$(System.ArtifactsDirectory)/msbuild/artifacts/bin'
69+
itemPattern: "MSBuild.Bootstrap/**"
70+
displayName: Download specified msbuild build
71+
72+
- powershell: |
73+
$sdk = "dotnet-sdk-win-x64"
74+
75+
Write-Host "Extracting $(System.ArtifactsDirectory)/installer/$sdk.zip"
76+
Expand-Archive "$(System.ArtifactsDirectory)/installer/$sdk.zip" -DestinationPath "$(Pipeline.Workspace)/exp-dotnet/$sdk"
77+
78+
$dotnetDirectory = Get-ChildItem -Directory -Path "$(Pipeline.Workspace)/exp-dotnet/$sdk/sdk"
79+
$dotnetVersion = $dotnetDirectory.Name
80+
Write-Host "Detected dotnet version: $dotnetVersion"
81+
82+
Write-Host "Updating MSBuild dlls."
83+
$(Build.SourcesDirectory)/scripts/Deploy-MSBuild.ps1 `
84+
-destination "$(Pipeline.Workspace)/exp-dotnet/$sdk/sdk/$dotnetVersion" `
85+
-bootstrapDirectory "$(System.ArtifactsDirectory)/msbuild/artifacts/bin/MSBuild.Bootstrap" `
86+
-configuration Release `
87+
-makeBackup $false
88+
89+
Write-Host "Compressing dotnet sdk files"
90+
Get-ChildItem -Path "$(Pipeline.Workspace)/exp-dotnet/$sdk" | Compress-Archive -DestinationPath "$(Pipeline.Workspace)/artifacts/$sdk.zip"
91+
92+
displayName: Dogfood msbuild dlls to dotnet sdk win-x64
93+
94+
- powershell: |
95+
$sdk = "dotnet-sdk-linux-x64"
96+
97+
mkdir "$(Pipeline.Workspace)/exp-dotnet/$sdk"
98+
99+
Write-Host "Extracting $(System.ArtifactsDirectory)/installer/$sdk.tar.gz"
100+
tar -xzvf "$(System.ArtifactsDirectory)/installer/$sdk.tar.gz" -C "$(Pipeline.Workspace)/exp-dotnet/$sdk"
101+
102+
$dotnetDirectory = Get-ChildItem -Directory -Path $(Pipeline.Workspace)/exp-dotnet/$sdk/sdk
103+
$dotnetVersion = $dotnetDirectory.Name
104+
Write-Host "Detected dotnet version: $dotnetVersion"
105+
106+
Write-Host "Updating MSBuild dlls."
107+
$(Build.SourcesDirectory)/scripts/Deploy-MSBuild.ps1 `
108+
-destination "$(Pipeline.Workspace)/exp-dotnet/$sdk/sdk/$dotnetVersion" `
109+
-bootstrapDirectory "$(System.ArtifactsDirectory)/msbuild/artifacts/bin/MSBuild.Bootstrap" `
110+
-configuration Release `
111+
-makeBackup $false
112+
113+
Write-Host "Compressing dotnet sdk files"
114+
tar -czvf "$(Pipeline.Workspace)/artifacts/$sdk.tar.gz" -C "$(Pipeline.Workspace)/exp-dotnet/$sdk" .
115+
displayName: Dogfood msbuild dlls to dotnet sdk linux-x64
116+
117+
- task: PublishPipelineArtifact@1
118+
inputs:
119+
targetPath: '$(Pipeline.Workspace)/artifacts'
120+
artifactName: ExperimentalDotnet
121+
parallel: true
122+
condition: always()
123+
displayName: Publish crank assests artifacts

scripts/Deploy-MSBuild.ps1

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ Param(
55
[ValidateSet('Debug','Release')]
66
[string] $configuration = "Debug",
77
[ValidateSet('Core','Desktop', 'Detect', 'Full')]
8-
[string] $runtime = "Detect"
8+
[string] $runtime = "Detect",
9+
[string] $bootstrapDirectory = "",
10+
[bool] $makeBackup = $true
911
)
1012

1113
Set-StrictMode -Version "Latest"
@@ -15,9 +17,9 @@ function Copy-WithBackup ($origin, $destinationSubFolder = "") {
1517
$directoryPart = [IO.Path]::Combine($destination, $destinationSubFolder, $origin.IntermediaryDirectories)
1618
$destinationPath = Join-Path -Path $directoryPart (Split-Path $origin.SourceFile -leaf)
1719

18-
$backupInto = [IO.Path]::Combine($BackupFolder, $destinationSubFolder)
20+
if (($makeBackup) -and (Test-Path $destinationPath -PathType Leaf)) {
21+
$backupInto = [IO.Path]::Combine($BackupFolder, $destinationSubFolder)
1922

20-
if (Test-Path $destinationPath -PathType Leaf) {
2123
# Back up previous copy of the file
2224
if (!(Test-Path $backupInto)) {
2325
[system.io.directory]::CreateDirectory($backupInto)
@@ -45,10 +47,15 @@ function FileToCopy([string] $sourceFileRelativeToRepoRoot, [string] $intermedia
4547

4648
# TODO: find most-recently-built MSBuild and make it default $configuration
4749

48-
$BackupFolder = New-Item (Join-Path $destination -ChildPath "Backup-$(Get-Date -Format FileDateTime)") -itemType directory -ErrorAction Stop
49-
5050
Write-Verbose "Copying $configuration MSBuild to $destination"
51-
Write-Host "Existing MSBuild assemblies backed up to $BackupFolder"
51+
52+
if ($makeBackup) {
53+
$BackupFolder = New-Item (Join-Path $destination -ChildPath "Backup-$(Get-Date -Format FileDateTime)") -itemType directory -ErrorAction Stop
54+
Write-Host "Existing MSBuild assemblies backed up to $BackupFolder"
55+
}
56+
else {
57+
Write-Host "Existing MSBuild assemblies won't be backed up"
58+
}
5259

5360
if ($runtime -eq "Detect") {
5461
if ($destination -like "*dotnet*sdk*") {
@@ -72,7 +79,12 @@ if ($runtime -eq "Desktop") {
7279
$targetFramework = "net8.0"
7380
}
7481

75-
$bootstrapBinDirectory = "artifacts\bin\MSBuild.Bootstrap\$configuration\$targetFramework"
82+
# If bootstrap directory is not defined in parameters, use the default location
83+
if ($bootstrapDirectory -eq "") {
84+
$bootstrapDirectory = "artifacts\bin\MSBuild.Bootstrap"
85+
}
86+
87+
$bootstrapBinDirectory = "$bootstrapDirectory\$configuration\$targetFramework"
7688

7789
$filesToCopyToBin = @(
7890
FileToCopy "$bootstrapBinDirectory\Microsoft.Build.dll"

0 commit comments

Comments
 (0)