Change SDK version 3.1 to 2.1

Asked

Viewed 242 times

1

I made all my ASPNET Core API 3.1 but when I went to configure the CICD, Nuget Restore accuses version error... Speaking I have to use a version 2.1 or lower. (error to follow)

'##[error]The nuget command failed with Exit code(1) and error(C: Program Files dotnet sdk 2.1.515 Sdks Microsoft.NET.Sdk targets Microsoft.NET.Targetframeworkinference.targets(137,5): error NETSDK1045: The Current . NET SDK does not support Targeting . NET Core 3.1. Either target . NET Core 2.1 or Lower, or use a version of the . NET SDK that Supports . NET Core 3.1.'

For what I searched, I need to go in the project -> properties and change the version:

inserir a descrição da imagem aqui

But when I do this, my startup.Cs class accuses errors: inserir a descrição da imagem aqui

and

inserir a descrição da imagem aqui

Does anyone know if this is really the right way or if I need to do something?

thanks in advance.

1 answer

1


There is a a post on the original Stackoverflow which details all possible causes of this behavior. In literal translation:

These days, I had to overcome this problem in several machines/containers of different development: finally, found nothing less than 6 different reasons that could cause this type of error:

  • Missing . NET Core 3 SDK (x86 or x64) Support for. NET display
  • Core SDK not activated on VS2019 VS2017 instead of VS2019 Path
  • Incorrect SDK path in PATH environment variables
  • Incorrect SDK path in Msbuildsdkspath environment variables
  • Incorrect SDK path in the project’s global.json file

The alternative solutions for these scenarios are quite easy to understand, you basically need to install the appropriate SDK or remove "offensive" references of the SDK. However, I did my best to document them all in this post on my blog. (n.t.: blog in English.)

In short: Instead of refactoring your code to 2.1 (which is an interstitial version), install . NET Core 3 SDK.

  • Thanks for the answer. The problem is not itself in my machine. It works perfectly. I have the SDK 3 in my machine... The problem is in the portal devops when the pipe will run for CI...

  • @Lucasbersot maybe this post will help you then: "Setting up Azure Devops CI/CD for a . NET Core 3.1 Web App Hosted in Azure App Service for Linux" - https://www.hanselman.com/blog/SettingUpAzureDevOpsCICDForANETCore31WebAppHostedInAzureAppServiceForLinux.aspx

Browser other questions tagged

You are not signed in. Login or sign up in order to post.