The .NET Core 2.0 CLI (dotnet.exe
), works on all platforms (Windows, Mac, and Linux) and provides core NuGet features such as installing, restoring, and publishing packages.
.csproj
), which is helpful in most scenarios.The dotnet CLI provides the following essential nuget.exe
commands.
Adds a package reference to a project file.
Add Newtonsoft.Json NuGet package to a project.
dotnet add package Newtonsoft.Json
Add a specific version of a package to a project.
dotnet add ToDo.csproj package Microsoft.Azure.DocumentDB.Core -v 1.0.0
Add a package using a specific NuGet source.
dotnet add package Microsoft.AspNetCore.StaticFiles -s https://dotnet.myget.org/F/dotnet-core/api/v3/index.json
Removes package reference from a project file.
Removes Newtonsoft.Json
NuGet package from a project in the current directory.
dotnet remove package Newtonsoft.Json
Restores the dependencies and tools of a project.
Restore dependencies and tools for the project in the current directory.
dotnet restore
Restore dependencies and tools for the app1 project found in the given path.
dotnet restore ~/projects/app1/app1.csproj
Restore the dependencies and tools for the project in the current directory using the file path provided as the source.
dotnet restore -s c:\packages\mypackages
Restore the dependencies and tools for the project in the current directory using the two file paths provided as sources.
dotnet restore -s c:\packages\mypackages -s c:\packages\myotherpackages
Restore dependencies and tools for the project in the current directory and shows only minimal output.
dotnet restore --verbosity minimal
Clears or lists local NuGet resources.
Displays the paths of all the local cache directories (http-cache directory, global-packages cache directory, and temporary cache directory).
dotnet nuget locals �l all
Displays the path for the local http-cache directory.
dotnet nuget locals --list http-cache
Clears all files from all local cache directories (http-cache directory, global-packages cache directory, and temporary cache directory):
dotnet nuget locals --clear all
Clears all files in the local global-packages cache directory.
dotnet nuget locals -c global-packages
Clears all files in the local temporary cache directory.
dotnet nuget locals -c temp
Packs the code into a NuGet package.
Pack the project in the current directory.
dotnet pack
Pack the app1 project.
dotnet pack ~/projects/app1/project.csproj
Pack the project in the current directory and place the resulting packages into the nupkgs folder.
dotnet pack --output nupkgs
Pushes a package to the server and publishes it.
Pushes foo.nupkg to the default push source, specifying an API key:
dotnet nuget push foo.nupkg -k 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a
Push foo.nupkg to the custom push source https://customsource, specifying an API key:
dotnet nuget push foo.nupkg -k 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a -s https://customsource/
Pushes foo.nupkg to the default push source:
dotnet nuget push foo.nupkg
Pushes foo.symbols.nupkg to the default symbols source:
dotnet nuget push foo.symbols.nupkg
Pushes foo.nupkg to the default push source, specifying a 360-second timeout:
dotnet nuget push foo.nupkg --timeout 360
Pushes all .nupkg files in the current directory to the default push source:
dotnet nuget push *.nupkg
Deletes or unlists a package from the server.
Deletes version 1.0 of package Microsoft.AspNetCore.Mvc:
dotnet nuget delete Microsoft.AspNetCore.Mvc 1.0
Deletes version 1.0 of package Microsoft.AspNetCore.Mvc, not prompting user for credentials or other input:
dotnet nuget delete Microsoft.AspNetCore.Mvc 1.0 --non-interactive