I'm highly confused by the NuGet's documentation about the differences between dotnet.exe
and nuget.exe
. Let me phrase my understanding about the whole .NET ecosystem and introduce where I get confused:
Ok so we have .NET which is a framework for building all kinds of applications. .NET has several implementations - namely .NET Framework versions 1 - 4.8, then .NET Core 1.0 - 3.1, and then .NET 5 .
In addition to this, we have what is called ".NET Standard" - which is a specification of APIs which implementations conform to so that applications written for a specific standard can surely run on any implementation that conform to this version of .NET Standard.
Every application or library written in .NET specifies the TargetFramework
which it is targeting. This means that this application can only run on these implementations of .NET.
So far so good?
Now, we have NuGet, which is the package manager for .NET projects. NuGet has 2 CLI tools, and when introducing them, the docs tells us about dotnet.exe
as such:
CLI tool for .NET Core and .NET Standard libraries, and for any SDK-style project such as one that targets .NET Framework. Included with the .NET Core SDK and provides core NuGet features on all platforms. ...
Ok - what does it mean "for .NET Core and .NET Standard libraries"? Does it mean that libraries that are targeting .NET Core and .NET Standard should be packaged using dotnet.exe
?
Furthermore - what is meant by "any SDK-style project such as one that targets .NET Framework"? Maybe I didn't get the english correctly - does this mean "any SDK-style project", and a project that targets .NET Framework is always such a project? Or does it mean "any SDK-style project that targets .NET Framework"? I really didn't get it. Is there a relation between whether or not a project is a SDK-project or a non-SDK project to what .NET implementation it targets?
CodePudding user response:
The dotnet
(dotnet.exe
on Windows) CLI tool provides nuget functionality. It works out of the box for all .NET Core, .NET Standard and .NET >= 5 projects. You should be able to package any projects targeting .NET Core, .NET 5 or newer and .NET Standard using the dotnet
tool. nuget
will still work, but dotnet
is easier and more "common" and has better documentation in this context.
.NET has used project files for a long time now. "SDK-style project file" is a new variant of the traditional project files, used with .NET Core, .NET >= 5.
You can indicate that an project file is an SDK-style project by marking it as such, either in the Project
xml element, or by adding a separate SDK
element, or even Import
ing an Sdk.props
file.
.NET Core, and .NET >= 5 are SDK style projects by default. .NET Framework projects are not and you have explicitly migrate them to SDK-style yourself.
In other words, if you want to use dotnet
to package things as nuget and you are working with a .NET Framework application, you need to migrate to the new SDK-style project because you can use dotnet
to create nuget packages.
More information: https://docs.microsoft.com/en-us/dotnet/core/project-sdk/overview