Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install .NET 6.0.x SDK. Remove DotNetCoreVersion param. Undo DOTNET_ROLL_FORWARD - take 2 #5405

Merged
merged 5 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions eng/pipelines/templates/stages/archetype-sdk-tool-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ parameters:
- name: TestDirectory
type: string
default: ''
- name: DotNetCoreVersion
type: string
default: ''
- name: NoWarn
type: boolean
default: false
Expand Down Expand Up @@ -65,8 +62,6 @@ stages:

steps:
- template: /eng/pipelines/templates/steps/install-dotnet.yml
parameters:
DotNetCoreVersion: ${{ parameters.DotNetCoreVersion }}

- script: 'dotnet pack /p:ArtifactsPackagesDir=$(packagesToPublishDir) $(Warn) -c Release'
displayName: 'Build and Package'
Expand Down Expand Up @@ -115,8 +110,6 @@ stages:

steps:
- template: /eng/pipelines/templates/steps/install-dotnet.yml
parameters:
DotNetCoreVersion: ${{ parameters.DotNetCoreVersion }}

- template: /eng/pipelines/templates/steps/produce-net-standalone-packs.yml
parameters:
Expand Down Expand Up @@ -144,8 +137,6 @@ stages:

steps:
- template: /eng/pipelines/templates/steps/install-dotnet.yml
parameters:
DotNetCoreVersion: ${{ parameters.DotNetCoreVersion }}

- script: 'dotnet test /p:ArtifactsPackagesDir=$(Build.ArtifactStagingDirectory) $(Warn) --logger trx'
displayName: 'Test'
Expand All @@ -161,7 +152,7 @@ stages:
condition: succeededOrFailed()
inputs:
testResultsFiles: '**/*.trx'
testRunTitle: $(System.JobDisplayName) ${{ parameters.DotNetCoreVersion }}
testRunTitle: $(System.JobDisplayName)
testResultsFormat: 'VSTest'
mergeTestResults: true

Expand Down
44 changes: 21 additions & 23 deletions eng/pipelines/templates/steps/install-dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
parameters:
# Use this parameter if you want to override the .NET SDK set by global.json
- name: DotNetCoreVersion
type: string
default: ''

steps:
# We set DOTNET_ROLL_FORWARD so that .NET assemblies targeting older versions of .NET can run on newer ones.
# See also:
# https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet#options-for-running-an-application
# https://learn.microsoft.com/en-us/dotnet/core/runtime-discovery/troubleshoot-app-launch?pivots=os-windows#required-framework-not-found
# https://aka.ms/dotnet/app-launch-failed
# https://learn.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?view=azure-devops&tabs=powershell
# https://learn.microsoft.com/en-us/azure/devops/pipelines/process/set-variables-scripts?view=azure-devops&tabs=powershell
- pwsh: |
echo "##vso[task.setvariable variable=DOTNET_ROLL_FORWARD;]Major"
displayName: "Set DOTNET_ROLL_FORWARD to Major"
# https://learn.microsoft.com/azure/devops/pipelines/tasks/reference/use-dotnet-v2?view=azure-pipelines

# We aim to keep .NET SDK coming from global.json to bethe newest, to enable us to use the latest & greatest,
# and allow us to gradually migrate our .NET sources to such version.
# About global.json: https://learn.microsoft.com/en-us/dotnet/core/tools/global-json
- task: UseDotNet@2 # About UseDotNet@2 task: https://learn.microsoft.com/azure/devops/pipelines/tasks/reference/use-dotnet-v2?view=azure-pipelines
displayName: "Use .NET SDK from global.json"
retryCountOnTaskFailure: 3
inputs:
useGlobalJson: true

# We install .NET 6.0.x SDK in addition to .NET coming from global.json because most of our tools target 6.0.x.
# Once we migrate all tools to a newer .NET version, we should update this to install that version instead.
- task: UseDotNet@2
displayName: "Use .NET SDK ${{ coalesce( parameters.DotNetCoreVersion, 'from global.json') }}"
displayName: "Use .NET SDK 6.0.x"
retryCountOnTaskFailure: 3
inputs:
${{ if eq( parameters.DotNetCoreVersion, '') }}:
useGlobalJson: true
${{ else }}:
version: ${{ parameters.DotNetCoreVersion }}
# We must install sdk, not just runtime, as it is required by some of our tools, like test-proxy.
# For additional context, see PR: https://github.com/Azure/azure-sdk-tools/pull/5405
konrad-jamrozik marked this conversation as resolved.
Show resolved Hide resolved
packageType: sdk
version: 6.0.x
# performMultiLevelLookup comes into play when given .NET executable target runtime is different
# than the installed .NET SDK. Without this, such runtime would not be found.
performMultiLevelLookup: true

# Future work: add NuGet packages caching. See:
# https://github.com/Azure/azure-sdk-tools/issues/5086
# https://github.com/Azure/azure-sdk-tools/issues/5086