Skip to content

Commit 57c4637

Browse files
authored
Pin to .NET8 SDK (#9825)
* Pin to .NET8 SDK * Pin to .NET8 SDK * Install .net sdk not runtime * Install .net sdk for initialize pipeline * Handle rate limiting as warning, continue * Improve warning message
1 parent d9b24ac commit 57c4637

File tree

4 files changed

+41
-21
lines changed

4 files changed

+41
-21
lines changed

azure-pipelines.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,17 @@ jobs:
2424
demands:
2525
- ImageOverride -equals MMS2019TLS
2626
steps:
27+
- task: UseDotNet@2 # The pinned SDK we use to build
28+
displayName: 'Install .NET SDK from global.json'
29+
inputs:
30+
packageType: sdk
31+
useGlobalJson: true
2732
- task: PowerShell@2
2833
displayName: 'Initialize'
2934
name: Initialize
3035
inputs:
3136
filePath: '$(Build.Repository.LocalPath)\build\initialize-pipeline.ps1'
37+
showWarnings: true
3238

3339
- job: BuildArtifacts
3440
dependsOn: InitializePipeline

build/initialize-pipeline.ps1

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@ Write-Host "BUILD_REASON: '$buildReason'"
55
Write-Host "BUILD_SOURCEBRANCH: '$sourceBranch'"
66

77
if ($buildReason -eq "PullRequest") {
8-
# parse PR title to see if we should pack this
9-
$response = Invoke-RestMethod api.github.com/repos/$env:BUILD_REPOSITORY_ID/pulls/$env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER
10-
$title = $response.title.ToLowerInvariant()
11-
Write-Host "Pull request '$title'"
12-
if ($title.Contains("[pack]")) {
13-
Write-Host "##vso[task.setvariable variable=BuildArtifacts;isOutput=true]true"
14-
Write-Host "Setting 'BuildArtifacts' to true."
8+
try {
9+
# parse PR title to see if we should pack this
10+
$response = Invoke-RestMethod api.github.com/repos/$env:BUILD_REPOSITORY_ID/pulls/$env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER
11+
$title = $response.title.ToLowerInvariant()
12+
Write-Host "Pull request '$title'"
13+
if ($title.Contains("[pack]")) {
14+
Write-Host "##vso[task.setvariable variable=BuildArtifacts;isOutput=true]true"
15+
Write-Host "Setting 'BuildArtifacts' to true."
16+
}
17+
}
18+
catch {
19+
Write-Warning "Failed to get pull request title. Artifacts will not be built or packed."
20+
Write-Warning $_
1521
}
1622
}
1723

@@ -27,4 +33,4 @@ Import-Module $PSScriptRoot\Get-AzureFunctionsVersion -Force
2733
$version = Get-AzureFunctionsVersion $buildNumber $buildNumber
2834

2935
Write-Host "Site extension version: $version"
30-
Write-Host "##vso[build.updatebuildnumber]$version"
36+
Write-Host "##vso[build.updatebuildnumber]$version"

build/install-dotnet.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
steps:
2-
- task: PowerShell@2
2+
- task: UseDotNet@2 # Needed by some of our test resources
33
displayName: 'Install .NET 3.1'
44
inputs:
5-
targetType: 'inline'
6-
script: |
7-
Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile 'dotnet-install.ps1'
8-
./dotnet-install.ps1 -InstallDir 'C:\Program Files\dotnet' -Verbose -Channel 3.1
9-
- task: PowerShell@2
5+
packageType: sdk
6+
version: 3.1.x
7+
- task: UseDotNet@2 # Needed by our projects and CI steps
108
displayName: 'Install .NET 6'
119
inputs:
12-
targetType: 'inline'
13-
script: |
14-
Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile 'dotnet-install.ps1'
15-
# Official release versions can be found at: https://dotnet.microsoft.com/download/dotnet/6.0
16-
# Newer versions can be found at: https://github.com/dotnet/installer#installers-and-binaries
17-
./dotnet-install.ps1 -InstallDir 'C:\Program Files\dotnet' -Verbose -Channel 6.0
18-
& dotnet --info
10+
packageType: sdk
11+
version: 6.x
12+
- task: UseDotNet@2 # The pinned SDK we use to build
13+
displayName: 'Install .NET SDK from global.json'
14+
inputs:
15+
packageType: sdk
16+
useGlobalJson: true

global.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"sdk": {
3+
"version": "8.0.101",
4+
"rollForward": "latestFeature"
5+
},
6+
"msbuild-sdks": {
7+
"Microsoft.Build.NoTargets": "3.7.56",
8+
"Microsoft.Build.Traversal": "4.1.0"
9+
}
10+
}

0 commit comments

Comments
 (0)