Why installation of .NET SDK 5.0 (after SDK 2.1 was installed) affected my solution with only netstandard2.0 or netcoreapp2.1 projects?

SaShka-K1 0 Reputation points
2023-05-25T18:11:02.8133333+00:00

Why installation of additional .NET SDK 5.0 (after SDK 2.1 was installed already) affected my solution, all projects of which have TargetFramework either netstandard2.0 or netcoreapp2.1? I expected, that I need only SDK 2.1. And installation of SDK 5.0 (I thought) should not affect this solution.

**
Below I will say about all effects that appeared in my solution after I installed .NET SDK 5.0

1. Projects appearance
So, as I said, I have a Visual Studio solution with some projects in it. All the projects have a TargetFramework either netstandard2.0 or netcoreapp2.1. I installed .NET SDK 2.1.818 (from here) (it was the only installed SDK at that moment).

1.a) When I opened the solution all dependencies had yellow warning sign. But it was no warnings in an "Error list":
image

Then I installed one more SDK: .NET SDK 5.0.408 (from here)
And all this signs are gone.

1.b) Also projects properties was displayed different:
Left - only SDK 2.1 is installed, Right - both 2.1 & 5.0 are installed
User's image

My question is - Why installing of SDK 5 affects the solution, all projects of which have a TargetFramework either netstandard2.0 or netcoreapp2.1?
May be it's caused somehow by the fact, (f.e.) that one of the nuGet-dependencies - Microsoft.CSharp (4.7.0) has one of it's dependencies - .NETCore 5.0:
User's image

**
2. Builds difference
But the main question is that build artifacts are not equal when I built the solution while only SDK 2.1 was installed compared with another build after SDK 5.0 was installed also. I compared build artifacts and the main differences are (I will call these two builds "2.1 build" and "5.0 build":

2.a) deps.jsons:

  • All assemblies deps.jsons had runtimeTarget->signature:
    -2.1 build: NOT empty
    -5.0 build: empty
  • One of my assemblies deps.json had additional block about a couple of its dependency projects in "targets"->".NETCoreApp,Version=v2.1" and in "libraries" sections in 2.1 build, but had NOT this block at 5.0 build
    !!: And in my case this difference caused another behaviour of the program

2.b) All jsons in projects obj folders (e.g. project.assets.json) had different:

  • addersses of nuget:
    -2.1 build: www.nuget.org/api/v2
    -5.0 build: api.nuget.org/v3/index.json
    • And different "project"->"frameworks"->"netcoreapp2.1"->"imports" and "runtimeIdentifierGraphPath" sections:
      Left - 2.1 build (only SDK 2.1 is installed), Right - 5.0 build (both 2.1 & 5.0 are installed)
      User's image

I'll repeat my question:
So, help me please to understand, why installation of additional SDK 5.0 had such effect? I expected, as all projects of solution have TargetFramework either netstandard2.0 or netcoreapp2.1, I need only SDK 2.1. And installation of SDK 5.0 (I expected) should not affect this solution.

Developer technologies | .NET | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jiachen Li-MSFT 34,221 Reputation points Microsoft External Staff
    2023-05-26T08:36:57.8366667+00:00

    Hi @SaShka-K1 ,

    In previous versions, .NET Core was the framework for building cross-platform applications, while .NET Standard was the specification for sharing code. Developers need to choose to use . NET Core as the runtime framework for your application and choose a . The NET Standard version serves as the target framework for shared code.

    However, starting with .NET 5, Microsoft decided to merge .NET Core and .NET Standard into a single .NET platform. This way, you can use it simultaneously in a single project. .NET all the features, and no longer need to choose different target frameworks for applications and shared code.

    So installing the .NET 5 SDK will affect both of your projects.

    And the .NET 5 SDK is forward compatible with some .NET Framework versions, enabling you to work in the . These versions of class libraries and applications are used in the NET 5 development environment.

    Best Regards.

    Jiachen Li


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.