Reputation: 276
I have a long stable Azure DevOps pipeline to deploy a .NET core application, and in one of the Agent Jobs I have some tasks to deploy (drop and recreate) some databases using dotnet ef
commands.
This release pipeline has been working smoothly from months now.
I am explicitly using .NET Core SDK 2.2 in the Agent Job, so the first task of the Agent Job is to install SDK 2.2.100. This Agent Job runs on a Hosted Windows 2019 with VS2019 agent pool.
The problem is that a couple of days ago (Sep 27) the dotnet restore
task I'm using before the dotnet ef
commands, suddenly started to use .NET Core SDK 3.0, breaking my pipeline, since dotnet ef command-line tool is not included anymore as a part of the SDK. There was no change on the code related to that, nor in the pipeline, so I guess something changed on Microsoft side.
Before:
After:
I managed to patch the issue adding a new task to install the EF tools (dotnet update --global dotnet-ef
), but this is a just a patch. I need to understand the root cause of the error so I can understand if there's something wrong with my pipeline or with my solution-
Does anyone know what happened here, or anyone can help me to fix my pipeline to force it to use SDK 2.2 instead of SDK 3.0 as it should be?
Upvotes: 4
Views: 3107
Reputation: 3762
Just search for task "Use .NET Core", add it before "Restore" task and set you desired major .NET Core version.
Upvotes: -1
Reputation: 76910
Does anyone know what happened here, or anyone can help me to fix my pipeline to force it to use SDK 2.2 instead of SDK 3.0 as it should be?
I have reproduced this issue on my side. That because you are using the old version DotNetCoreInstaller
task(0.*
).
To resolve this issue, you need to use the latest version (2.*
), so the task like:
- task: UseDotNet@2
displayName: 'Use .Net Core sdk 2.2.100'
inputs:
version: 2.2.100
Test details:
When I use the old version DotNetCoreInstaller@0
on the hosted agent Hosted Windows 2019 with VS 2019:
I got the same result:
But when I change the task version to UseDotNet@2
, it works fine:
Besides,
so I guess something changed on Microsoft side.
Yes, Microsoft released .NET Core 3.0.0 at 2019-09-23. Then the VM uses the latest version of ASP .NET Core 3.0.100
.
Hope this helps.
Upvotes: 3
Reputation: 21
Last Friday I encountered the same problem within our pipeline. The build failed because the SDK did not recognize the commands that were being executed.
As you have already described, the VM now uses the latest version of ASP .NET Core -> 3.0. So I placed the next step at the top of my azure pipeline.yml.
- task: UseDotNet@2
displayName: 'Install .NET Core SDK'
inputs:
packageType: 'sdk'
version: '2.2.*'
This is also possible by using the following option in the Tasks menu with the correct settings. (With the SDK version for your project)
This ensures that the VM installs and uses the correct version of the .NET Core SDK. Because of this change, the build of the project uses .NET Core 2.2.* and not .NET Core 3.0 in the pipeline.
I hope this solution works and this answers your question.
Upvotes: 2