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
.NET
Microsoft Technologies based on the .NET software framework.
3,398 questions
0 comments No comments
{count} votes

7 answers

Sort by: Newest
  1. Bruce (SqlWork.com) 56,771 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

  2. Wonderful World 21 Reputation points
    2022-04-23T17:14:47.173+00:00

    There are two projects (1) .NET Core 3.1 (2) .netstanadard2.0 in the same solution. The error is happening in the .netstandard project when the build tries to build, pack and publish to nuget. It does not have a reference to
    .net core 3.1
    .

    The
    nuget pack
    is the command run to build and pack the assemblies. When that command is run, nuget may be trying to build the project by looking at the targetframework in the
    csproj
    file. It can't find the version of msbuild or dotnet for
    netstandard2.0
    framework and may be erroring out.

    1. Can a
      netstandard2.0
      assembly be compiled with .net core 3.1 SDK by using the command
      dotnet build
      ?
    2. Are we using an outdated nuget tools which can't understand the
      netstandard2.0
      framework?

    We have a plan to migrate the apps to .NET 6 by the end of this year.

    0 comments No comments

  3. Bruce (SqlWork.com) 56,771 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. Wonderful World 21 Reputation points
    2022-04-23T13:07:53.48+00:00

    Our servers have already .NET Core 3.1 SDK . The project also has the setting that you shown above. But the command dotnet build fails!

    We have nuget package manager which fails with the following error message. This build failure happened after .NET 2.0 SDK was uninstalled. So, we assume the corresponding dotnet SDK is unavailable.

    Is it possible that the issue is with the nuget package manager?

    195737-image001.png

    0 comments No comments

  5. Bruce (SqlWork.com) 56,771 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