question

WonderfulWorld-6345 avatar image
0 Votes"
WonderfulWorld-6345 asked Bruce-SqlWork answered

Compiling netstandard20 libraries

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?



dotnet-standard
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Bruce-SqlWork avatar image
1 Vote"
Bruce-SqlWork answered

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


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

WonderfulWorld-6345 avatar image
0 Votes"
WonderfulWorld-6345 answered WonderfulWorld-6345 edited

That command is to create a netstandard project.

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Bruce-SqlWork avatar image
1 Vote"
Bruce-SqlWork answered WonderfulWorld-6345 commented

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



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

WonderfulWorld-6345 avatar image
0 Votes"
WonderfulWorld-6345 answered WonderfulWorld-6345 edited

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








image001.png (37.6 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Bruce-SqlWork avatar image
1 Vote"
Bruce-SqlWork answered Bruce-SqlWork edited

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

WonderfulWorld-6345 avatar image
0 Votes"
WonderfulWorld-6345 answered WonderfulWorld-6345 edited

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Bruce-SqlWork avatar image
1 Vote"
Bruce-SqlWork answered

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.