4

I followed these steps to install the .NET Core SDK. After I installed it, I can only find the ~/.nuget directory that was created, but I cannot find the executable nuget.

But in the Microsoft docs, it says that nuget can be install in Linux.

On Mac OSX and Linux, there are two ways to run the NuGet CLI: Install the .NET Core SDK, which includes the core NuGet capabilities. Downloads are also listed on github.com/dotnet/cli. If you need fuller capabilities, then use the second option below to use nuget.exe with Mono.

So how to install .NET Core nuget? sudo apt install nuget -y is Mono nuget, Microsoft's docs say it has some bugs, so I hope install the .NET Core nuget.

Eliah Kagan
  • 119,640

1 Answers1

2

You already have the .NET Core Nuget, because it is built into the .NET Core SDK that you installed. It just doesn't use any command called nuget.

When you install .NET Core, a command called dotnet is installed on your system. Access to Nuget functionality for .NET Core is integrated into that command. To add a Nuget package to a project (that you created with dotnet new), cd to the project folder and run:

dotnet add package Package

Replace Package with the name of the package. If you're accustomed to using the Install-Package PowerShell cmdlet in the Nuget shell in Visual Studio, the package name you would use with that is the same as what you use with dotnet add package. (Of course, not all packages support .NET Core, and some only support it.)

When you run dotnet restore, any Nuget packages that your project requires but are not present locally are fetched automatically. If you've run dotnet restore before, either explicitly or if you use Visual Studio Code and allow it to do so, then you may have seen this happening.

These are among the "core NuGet capabilities" that the Microsoft documentation you read was talking about.

For more information, see this answer, the dotnet add package documentation, and the dotnet restore documentation. Note that, in .NET Core 2.0 and higher, dotnet commands that you would usually have preceded by running dotnet restore will run it automatically unless you pass --no-restore. (So you may have used it implicitly already, even if you don't use an IDE.)

Eliah Kagan
  • 119,640