Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET Core SDK 2.2.2nn and 2.1.6nn do not work with Visual Studio 2017 #3124

Closed
KathleenDollard opened this issue Apr 12, 2019 · 15 comments
Closed
Milestone

Comments

@KathleenDollard
Copy link

.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 renamed Preview 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.

@bording
Copy link

bording commented Apr 12, 2019

While the "Compatible with Visual Studio 2017" button is helpful, I think https://dotnet.microsoft.com/download/dotnet-core/2.2 and https://dotnet.microsoft.com/download/dotnet-core/2.1 should also be modified to be very clear about this as well.

@poke
Copy link

poke commented Apr 12, 2019

What effect does this have on the support policy?

Let’s take for example 2.1.x which is a LTS release and which ASP.NET Core version has extended support on the .NET Framework (not Core). The usual guideline would be to install the latest patch version to make sure that security patches are applied. However, in order to do that, this would mean that one now has to upgrade to Visual Studio 2019 just to be able to continue using the latest patch release. Unfortunately, upgrading to the latest Visual Studio is not always a possibility for various reasons.

So does this mean that we’re essentially out of support in those situations? Or will 2.1.5xx will continue to receive patches that we can continue to use?

Fortunately, in this particular situation, I can apply patches myself since I need to reference explicit versions in .NET Framework ASP.NET Core projects anyway. But if I recall correctly, there have been some patches in the past that also fixed things in the SDK.

@Pilchie
Copy link
Member

Pilchie commented Apr 12, 2019

@poke we'll provide updated versions of both 2.1.5xx and 2.1.6xx when the runtime needs to be serviced.

@japj
Copy link

japj commented Apr 13, 2019

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

@Pilchie
Copy link
Member

Pilchie commented Apr 14, 2019

@japj That should not happen - SDK selection in VS2017 should skip the 2019 SDKs. @nguerrera what logs would help identify what's going wrong in @japj's case?

@nguerrera
Copy link
Contributor

nguerrera commented Apr 15, 2019

2017Update8

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.

@nguerrera nguerrera added this to the Discussion milestone Apr 15, 2019
@eldarj
Copy link

eldarj commented Apr 16, 2019

I am running VS 2017 on 15.9.x but still experienced the above described issue.

@KathleenDollard
Copy link
Author

@eldarj From a command line, can you type

dotnet --list-sdks

and paste the results here.

Thanks!

@eldarj
Copy link

eldarj commented Apr 24, 2019

@KathleenDollard Unfortunately I can't. I went through all my installed sdks, removed and installed only those which are proven to be working all fine, just as you described in the inital post/comment.

If I get time, I'll try to reproduce the issues I previously had and will check which exact versions were causing it.

@gulbanana
Copy link

gulbanana commented Jun 28, 2019

I'm using VS2019, but some of my coworkers cannot upgrade from VS2017. If I pin to 2.2.107 in global.json, will this work for both versions of visual studio? Further, is there a list anywhere of features that are are available in .3nn but missing in .1nn?

@KathleenDollard
Copy link
Author

@gulbanana You can pin to 2.2.107 if you ensure they have this on the machine. You can download the installer at https://dotnet.microsoft.com/download.

The new features in 2.2.2nn and 2.2.3nn are minor changes in MSBuild and NuGet that support features in Visual Studio 2019. Since you need to support 2017, this should not be a problem.

To keep things tidy, I would recommend you create new projects and do at least some testing of development configuration changes in Visual Studio 2017 (like changes to your csproj/vbproj files).

@nzdudeinsydney
Copy link

Qualys reports two separate vulnerabilities that are present on the system when Microsoft .NET Core SDK - 2.1.202 (x64) is installed:

QID 91515: A tampering vulnerability exists in the NuGet Package Manager for Linux and Mac that could allow an authenticated attacker to modify a NuGet packages folder structure.
QID 91531: A denial of service vulnerability exists when .NET Framework or .NET Core improperly handle web requests. / A denial of service vulnerability exists when .NET Framework and .NET Core improperly process RegEx strings. / A denial of service vulnerability exists when .NET Framework improperly handles objects in heap memory.

This seems to be the one:
dotnet/announcements#113

Every new update for Visual Studio 2017 puts a new version of .NET Core on the machine (most recent one in August 2019 was 2.1.508), but it also reinstalls 2.1.202. Is this actually needed? I've been uninstalling it and the users aren't complaining, but I'd love to know the reason why this keeps coming back, especially when it's not secure (or is it?)

I uninstalled it after the most recent update, then tried to update a component via a VSIX file and te VSIX installer downloaded 2.1.202 again and installed it.

Can you explain this?

@nguerrera
Copy link
Contributor

.NET Core SDK 2.1.202 is is the last version that carried a .NET Core 2.0.x runtime (it was during a transition period in version numbers where the runtime and sdk major and minor didn't match.) .NET Core 2.0 is end-of-life.

Do you have .NET Core 2.0 component(s) selected in the VS installer? Try to eliminate those.

Starting in 16.3 we've reduced this coupling of runtimes and SDKs. VS will give you latest SDK as a single thing and won't be able to install old SDKs like that. Only runtimes and templates will be pulled in for non-latest major.minor of .NET Core.

@sgaccenture
Copy link

sgaccenture commented Oct 18, 2019

@eldarj I am running VS 2017 on 15.9.x but still experienced the above described issue.

Installed SDK 2.2.108 (Windows) and using it with VS 2017 15.9.17 with no issue

dsplaisted pushed a commit to dsplaisted/sdk that referenced this issue Feb 19, 2020
….6 (dotnet#3124)

- Microsoft.DotNet.Cli.Runtime - 3.1.100-preview1.19506.6
@baronfel
Copy link
Member

Closing this as no longer relevant.

@baronfel baronfel closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests