sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Build issue when targeting .NET core 2.1 on machine with only .NET Core SDK 2.2

Open kakiyama1018 opened this issue 6 years ago • 5 comments

I'm trying to ship some code samples to users that will work regardless of whether they have .NET SDK 2.1 or 2.2.

According to... https://docs.microsoft.com/en-us/dotnet/core/versions/selection ... it states that:

"A given SDK supports a fixed set of frameworks, capped to the target framework of the runtime it ships with. For example, the .NET Core 2.0 SDK includes the .NET Core 2.0 runtime, which is an implementation of the netcoreapp2.0 target framework. The .NET Core 2.0 SDK supports netcoreapp1.0, netcoreapp1.1, and netcoreapp2.0 but not netcoreapp2.1 (or higher). You install the .NET Core 2.1 SDK to build for netcoreapp2.1."

As such, I've chosen to have... <TargetFramework>netcoreapp2.1</TargetFramework>. ... in the .csproj in hopes that the sample can be built on machines that have either .NET Core SDK 2.1 or 2.2.

However, we are running into the following build-time error on machines that simply have .NET Core SDK 2.2 installed:

error NU1202: Package Microsoft.NETCore.App 2.2.0 is not compatible with netcoreapp2.1 (.NETCoreApp,Version=v2.1). Package Microsoft.NETCore.App 2.2.0 supports: netcoreapp2.2 (.NETCoreApp,Version=v2.2)

Why can't we build an application that targets 2.1 on a machine that has .NET Core SDK 2.2, as the documentation implies to be allowed (since the target of 2.1 is lower than the SDK version that is installed on the machine)?

kakiyama1018 avatar May 25 '19 01:05 kakiyama1018

@nguerrera @dsplaisted @ericstj @safern can you please help here?

karelz avatar May 29 '19 22:05 karelz

2.2 SDK should work fine for targeting any previous netcoreapp. Double check that you're in a clean state: delete bin and obj and rerun dotnet build.

If that doesn't work please share a project file? Also this issue likely belongs in https://github.com/dotnet/sdk but I'll see if I can clarify / resolve before moving it.

ericstj avatar May 29 '19 23:05 ericstj

@kakiyama1018 can you please share your csproj or a small repro repository on github where we can try this ourselves. This is definitely a supported scenario that we validated in our automated tests. I am curious to understand what is going on here.

livarcocc avatar Jun 03 '19 15:06 livarcocc

I'm sorry for the delay. I was on vacation. I've created a repository and uploaded the files that may help reproduce the issue on your end.. The repository is at:

https://github.com/kakiyama1018/testcase

It contains:

  1. dotnetinfo.txt - output from executing "dotnet.exe --info"
  2. test2.csproj - project file that references the System.Data nuget package
  3. projfect.cs - the simple C# app code.
  4. build.output.txt

Please let me know if you need more information -or- if you have any suggestions to workaround/solve this issue.

kakiyama1018 avatar Jun 18 '19 00:06 kakiyama1018

Due to lack of recent activity, this issue has been labeled as 'stale'. It will be closed if no further activity occurs within 30 more days. Any new comment will remove the label.

github-actions[bot] avatar Jun 18 '25 04:06 github-actions[bot]

This issue will now be closed since it has been labeled 'stale' without activity for 30 days.

github-actions[bot] avatar Jul 18 '25 04:07 github-actions[bot]