This is sending me absolutely mad and I'm not sure if it's the diagnostics leading me astray, or I'm actually using the wrong versions
I have a build pipeline in azure, it builds a .NET Core minimal API. This thing has one endpoint. It works wonderfully well - when I merge to Main, a pipeline begins - it has many steps - but for the interests of this question lets assume it has two. These two:
Step 1: Install the .NET Core SDK
Step 2: Build a project
So, given:
steps:
- task: UseDotNet@2
displayName: 'Install SDK'
inputs:
version: 8.x
.... which produces
Successfully installed .NET Core sdk version 8.0.401.
Creating global tool path and pre-pending to PATH.
Finishing: Install .NET Core SDK
... in a subsequent step where I invoke:
inputs:
command: 'build'
... why does the diagnostic output show
Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version : 2.244.1
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
==============================================================================
##[warning]Resource file has already set to: /home/vsts/work/_tasks/DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b/2.244.1/node_modules/azure-pipelines-tasks-packaging-common/module.json
Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.
1.) how could it possibly build on 2.2/3 and then warn me not to use those things?
2.) why does it not use what I asked on step 1?
Has it actually not used .NET 8 here? Is the info message present for all? Am I missing something?
Please save me from the insanity...
UPDATE: TLDR - the warning is information and does not relate to your choices (not great, imo) - secondly, the version showing in diagnostics is the version of the Dotnet Task, which just so happens to be the same version as the end of life SDKs.... so it's just a diagnostic confusion issue.
Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents.
This is the info message built into the dotnet task version 2 in Azure DevOps. And it was added to dotnet task since 2020. All users who use dotnet task version 2 will see this info message.
Refer to this task commit related to the change: [DotnetCoreCLIV2]removing versions deprecation warning and making it info message
This info message is intended to remind projects using .net 2.2 and 3.0 that they need to use Use dotnet core task to install the required old SDK. It is not used to display the .net SDK version used by the current Pipeline.
It has no effect on your current build and can completely ignore this info log.
why does it not use what I asked on step 1?
Based on your Pipeline definition, the dotnet build should have used the dotnet version you set.
You can add an additional script task before the dotnet build task to run the command: dotnet --version
to confirm the dotnet version.
For example:
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk 8.x'
inputs:
version: 8.x
- script: 'dotnet --version'
displayName: 'Check dotnet version'
- task: DotNetCoreCLI@2
displayName: Build
inputs:
projects: '**/*.csproj'
arguments: '--configuration $(BuildConfiguration)'
When you check the script task, it will show the current dotnet version used in the Pipeline.
For example:
Currently, this info message does not support hiding in dotnet task version 2.
If you don't want to see info messages in the log, you can consider the following methods:
Change to use old version of dotnet task: DotNetCoreCLI@1 - .NET Core v1 task
Change to use script task(powershell/bash/cmd) to directly run dotnet command in Azure Pipelines.