4

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? Commented Oct 1, 2019 at 5:33
  • 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. Commented Oct 1, 2019 at 6:06
  • Do you think that setting a "demand" in the pipeline for the agent to netcore 2.2 would solve your problem? Commented Oct 1, 2019 at 6:27

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much! This solved the issue! Looks like a bug with the older version of the task, but version 2.* works fine now.
2

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.

4 Comments

I think it is a different Task then mine, not sure though.
ah right, his is use, which probably wont work if its not there, but I assume since it doesnt error out - doesnt happen
I'm using this task: - task: DotNetCoreInstaller@0 displayName: 'Use .NET Core sdk 2.2.100' inputs: version: 2.2.100
Your Task will install the SDK alongside the 3.0 SDK, but the pipeline will still use the 3.0 SDK. If you use the UseDotNet@2 it will install the correct SDK and set the path variables to that SDK, so the pipeline/ VM will use the installed SDK.
-1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.