How to Install Nuget from Command Line on Linux

NuGet for .NET Core on Linux

With recent .NET Core SDK releases, such as 1.0.0 RC4, NuGet is shipped with .NET Core. You can directly access NuGet by specifying it as a command with dotnet:

dotnet nuget

If the version of the .NET Core SDK does not support that you could look at downloading a nightly build of NuGet v4. There is a NuGet.CommandLine.Xplat NuGet package which supports being run on .NET Core. However, you need all its dependencies in the same folder and the NuGet package does not specify them. Downloading just the NuGet.CommandLine.Xplat NuGet package will not work directly. It will show an error about missing NuGet assemblies.

Your final option, which you said you did not want to do, is to install Mono.

How to install Nuget package using windows command line in C# project?

Install-Package is how you install via Visual Studio. The cmdlet to install a package via the CLI is nuget install <Package-Name>.

Please see this Microsoft Doc for reference:
https://docs.microsoft.com/en-us/nuget/consume-packages/install-use-packages-nuget-cli

How do I download a package from the command line with .NET Core from nuget?

dotnet add package --help

dotnet add package Newtonsoft.Json

Please refer to the github page https://github.com/dotnet/docs/blob/master/docs/core/tools/dotnet-add-package.md for more details.

NuGet on the Docker

I see the only reason you're trying to get nuget.exe is to add credentials. This page in the docs has links on how to authenticate to Azure Devops using the dotnet cli. Your use case falls into the "otherwise" sentence of the CI builds section, so you can use an environment variable to specify your PAT. Therefore, you don't actually need nuget.



Related Topics



Leave a reply



Submit