3
votes

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.

enter image description here

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:

enter image description here

After:

enter image description here

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?

3
Same problem here, did you find a solution?Matthias Müller
I had to install the EF tools for 3.0 using "dotnet update --global dotnet-ef", but I'm still looking for the root cause.Gustavo Vargas
Do you think that setting a "demand" in the pipeline for the agent to netcore 2.2 would solve your problem?Kristóf Tóth

3 Answers

3
votes

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:

enter image description here

I got the same result:

enter image description here

But when I change the task version to UseDotNet@2, it works fine:

enter image description here

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.

2
votes

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)

Tasks menu icon configuration

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.

-1
votes

Just search for task "Use .NET Core", add it before "Restore" task and set you desired major .NET Core version.

enter image description here

enter image description here