dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.73k stars 1.07k forks source link

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

Open kakiyama1018 opened 5 years ago

kakiyama1018 commented 5 years ago

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

netcoreapp2.1. ... 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)?
karelz commented 5 years ago

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

ericstj commented 5 years ago

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.

livarcocc commented 5 years ago

@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.

kakiyama1018 commented 5 years ago

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.