Compiling netstandard20 libraries

Wonderful World 21 Reputation points
2022-04-21T11:38:14.537+00:00

My IT department uninstalled .net core 2.0 SDK from our servers claiming that .net core 2.0 is no more supported by Microsoft.

Is there a version other than .net core 2.0 SDK which can be used to compile assemblies which have reference to netstandard20?

.NET Standard
.NET Standard
A formal specification of .NET APIs that are available on multiple .NET implementations.
505 questions
0 comments No comments
{count} votes

7 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 36,261 Reputation points
    2022-04-21T17:44:31.033+00:00

    they are correct, core 2.0-3.0 sdk is not supported (3.1 ends in December, net 5 in May). but .netstandard 2.0 is its own framework and still supported. you can build .netstandard 2.0 with classic 4.8 or .net 6.0 runtimes.

    dotnet new classlib -f netstandard2.0

    1 person found this answer helpful.
    0 comments No comments

  2. Bruce (SqlWork.com) 36,261 Reputation points
    2022-04-22T18:29:06.217+00:00

    no. it creates a project file with the framework set to netstandard 2.0

    <Project Sdk="Microsoft.NET.Sdk"> 
    
      <PropertyGroup> 
        <TargetFramework>netstandard2.0</TargetFramework> 
      </PropertyGroup> 
    
    </Project> 
    

    so just:

    dotnet build

    1 person found this answer helpful.
    0 comments No comments

  3. Bruce (SqlWork.com) 36,261 Reputation points
    2022-04-23T14:23:26.557+00:00

    is the error from building a .netstandard 2.0 library project, or from an application build using the library. A .netstandard library should not have a reference to core sdk.

    If it’s a library, then probably only worked with core projects. Just change from standard to a valid .net core frame, and update the nuget package to compatible versions.

    Also, why 3.1? It’s support ends in December.

    1 person found this answer helpful.
    0 comments No comments

  4. Bruce (SqlWork.com) 36,261 Reputation points
    2022-04-24T16:03:15.1+00:00

    .net standard 2.0 and the final version 2.1 are supported by .net 3.1+

    But nuget pack does not work with modern msbuild files, only the old 4.* format. You should use the dotnet pack or msbuild -t:pack commands instead.

    1 person found this answer helpful.
    0 comments No comments

  5. Wonderful World 21 Reputation points
    2022-04-22T01:59:32.827+00:00

    That command is to create a netstandard project.

    Is the command to build dotnet build -f netstandard2.0 ?

    0 comments No comments