.NET Core SDK 2.2.2nn and 2.1.6nn do not work with Visual Studio 2017
See original GitHub issue.NET Core SDK 2.2.2nn and 2.1.6nn do not work with Visual Studio 2017
.NET Core SDK 2.2.2nn and 2.1.6nn do not work with Visual Studio 2017. For example, 2.2.203 and 2.1.603 cause failures in Visual Studio 2017. To work on projects in Visual Studio 2017, use .NET Core SDK 2.2.1nn and 2.1.5nn, such as 2.2.106 and 2.1.506. You can install any combination of these SDKs side by side.
Details
You can find the SDKs on you machine using the following at a command prompt:
dotnet --list-sdks
Visual Studio 2017 can’t target .NET Core 2.2
If you receive the error message in Visual Studio 2017:
The current .NET SDK does not support targeting .NET Core 2.2. Either target .NET Core 2.1 or lower, or use a version of the .NET SDK that supports .NET Core 2.2.
If you downloaded the .NET Core SDK 2.2 between April 2 and April 12, 2019, the main .NET downloads page included only 2.2.2nn. Starting April 12th, a new button marked “Compatible with Visual Studio 2017” is provided to target 2.2.1nn.
Visual Studio 2017 can’t target .NET Core 2.1
If you receive this error message in Visual Studio 2017:
The current .NET SDK does not support targeting .NET Core 2.1. Either target .NET Core 2.0 or lower, or use a version of the .NET SDK that supports .NET Core 2.1.
This problem most often occurs because you manually uninstall the 2.1.5nn version. Simply reinstall it from the .NET Core 2.1 downloads page.
More information
Here is the draft of an article we are preparing for .NET Core documentation:
Solving Problems with .NET Core SDK Selection in Visual Studio
You may have .NET Core SDKs on your machine and still have problems with Visual Studio finding an appropriate one. This article explains why this happens and how you can fix your installation.
When Visual Studio can’t find an appropriate version of the .NET Core SDK, you’ll receive an error message. This may appear in the Error pane as NETSDK1045:
“The current .NET SDK does not support targeting .NET Core 2…”
You can check what .NET Core SDKs you have on your machine with the following command:
dotnet --list-sdks
Unless you have a global.json file, when you use dotnet
from the command line, the latest .NET Core SDK is used.
[TIP!] Open a command prompt and try to build with
dotnet build
. If the command line build works, but Visual Studio doesn’t suggestions in this article may help.
The last two digits of the .NET Core SDK version numbers are in the format are a patch number, which is represented by nn
in this article because we will continue to service them to include the latest runtimes. To find out more, vist the Overview of how .NET Core is versioned page.
Fixes for Common Problems
Visual Studio 2017 can’t target .NET Core 2.2
If you receive the error message in Visual Studio 2017:
The current .NET SDK does not support targeting .NET Core 2.2… Either target .NET Core 2.1 or lower, or use a version of the .NET SDK that supports .NET Core 2.2.
Use dotnet --list-sdks
to ensure you have .NET Core SDK 2.2.1nn. As an example, 2.2.106 would be a valid entry.
If you downloaded the .NET Core SDK 2.2 after April 2, 2019, version 2.2.2nn (such as 2.2.203) is listed first and is the highest version available. However, Visual Studio 2017 requires 2.2.1nn (such as 2.2.106). .NET Core SDK 2.2.2nn works with Visual Studio 2019. Visual Studio 2017 and Visual Studio 2019 can be installed side by side, but this requires both .NET Core SDK 2.2.1nn and .NET Core SDK 2.2.2nn to develop .NET Core 2.2 applications.
To download .NET Core SDK 2.2.2nn, visit the .NET downloads page.
Visual Studio 2017 can’t target .NET Core 2.1
If you receive this error message in Visual Studio 2017:
The current .NET SDK does not support targeting .NET Core 2.1. Either target .NET Core 2.0 or lower, or use a version of the .NET SDK that supports .NET Core 2.1.
Use dotnet --list-sdks
to ensure you have .NET Core SDK 2.1.5nn. As an example, 2.1.505 would be a valid entry.
This problem occurs of you manually uninstall the 2.1.5nn version.
The Visual Studio 2019 installation will not remove this file and Visual Studio 2017 will continue to work side by side.
To reinstall .NET Core SDK 2.1.5nn, visit the .NET downloads page.
Visual Studio 2019 can’t target .NET Core 3.0 Preview
If you receive this error message in Visual Studio 2019:
The current .NET SDK does not support targeting .NET Core 2.1. Either target .NET Core 2.0 or lower, or use a version of the .NET SDK that supports .NET Core 2.1.
Use dotnet --list-sdks
to ensure you have .NET Core SDK 3.0.100-preview… As an example, SDK 3.0.100-preview3-010431 would be a valid entry.
To install .NET Core SDK 3.0.1nn preview, visit the .NET downloads page.
In Visual Studio, go to Tools\Options\Projects and Solutions\.NET Core
and check the box Use Previews of the .NET Core SDK
.
[NOTE!] This option will be moving to
Tools\Options\Environment
and renamedPreview Features
in Visual Studio 2019 version 16.1 Preview 2.
If you are targeting .NET Core 3.0 preview, the C# language version will be C# 8.0 Preview by default allowing you to use new C# features.
Understand the relationship between .NET Core SDKs and Visual Studio build tools
Visual Studio has its own copies of tools like MSBuild, NuGet and the compilers. If you install the .NET Core workload, it also installs the .NET Core SDK which has versions of these tools and provides tasks and targets. These two versions are built from the same repositories, but target .NET Framework and .NET Core respectively.
When you build a .NET Core project in Visual Studio, it uses Visual Studio’s copy of MSBuild, but the tasks and targets are supplied from the selected version of the .NET Core SDK.
When you upgrade the .NET Core SDK, you get new tasks and targets. These new tasks and targets may contain features that are not supported by older versions of MSBuild. Like all of the .NET Core SDK, MSBuild is backwards compatible. It is not forwards compatible.
This generally works well, but requires a guarantee that the tasks and targets work with the MSBuild version. To ensure this, each .NET Core SDK indicates an MSBuild version range that is used by Visual Studio to determine compatibility. Versions of the .NET Core SDK that have a higher MSBuild identifier than expected are ignored by Visual Studio. In the normal case, this simply means you use the tasks and targets that were installed with your version of Visual Studio.
Because of this, you may have many versions of the .NET Core SDK on your machine and Visual Studio still fail to find one it considers appropriate. This is compounded by a poor error message, which we cannot fully correct because it is from the old version of the .NET Core SDK on your machine. Confusion is also compounded by a complex non-linear release matrix that makes it difficult to predict the right .NET Core SDK to select. We are working to improve all this.
The Visual Studio / .NET Core SDK support matrix
The last two digits of the .NET Core SDK version number are a patch number, which are represented by a nn
in this table. You can learn more about .NET Core SDK and .NET Core Runtime versioning at the Overview of how .NET Core is versioned page.
The following table shows which Visual Studio versions and .NET Core SDKs are compatible and how they are acquired if you are working with Visual Studio.
.NET Core SDK | .NET Core Runtime | Compatible Visual Studio | MSBuild | Notes |
---|---|---|---|---|
2.1.5nn | 2.1 | 2017 | 15 | Installed as part of VS 2017 version 15.9 |
2.1.6nn | 2.1 | 2019 | 16 | Installed as part of VS 2019 |
2.2.1nn | 2.2 | 2017 | 15 | Installed manually |
2.2.2nn | 2.2 | 2019 | 16 | Installed as part of VS 2019 |
3.0.1nn | 3.0 (Preview) | 2019 | 16 | Installed manually |
Visual Studio 2017 cannot work with .NET Core SDK 2.1.6nn or 2.2.2nn.
To find out more about removing older versions of the .NET Core Runtime and .NET Core SDK, visit the How to remove the .NET Core Runtime and SDK page.
To download the .NET Core SDK, visit the .NET downloads page.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:12
- Comments:14 (4 by maintainers)
Top GitHub Comments
This is why. Please update to 15.9 (aka 2017 update 9). We improved the sdk resolution to handle this as @pilchie describes beginning in 15.9.
I actually ran into this “by accident” by just installing VS2019. Suddenly none of my dotnet core projects would build anymore in VS2017 due to MSBuild 16 artifacts from the sdk (the error message in VS was not helping me) Eventually solved the issue by pinning the used sdk in global.json for VS2017 to work again. The issue here is that we use VS2017 side by side to VS2019 and installing VS2019 caused (default dotnet sdk resolution in) dotnet core projects in VS2017 to unexpectedly fail.
Note I was running VS2017Update8 next to VS2019RTM