For frequently-asked questions pertaining to NuGet.org, such as NuGet.org account questions, see NuGet.org frequently-asked questions.
General
What is required to run NuGet?
All the information around both UI and command-line tools is available in the Install guide.
Does NuGet support Mono?
The command-line tool, nuget.exe
, builds and runs typically under Windows. NuGet can run on Unix operating systems using mono
, but it is not officially supported by NuGet's Support Policy.
Mono has transferred ownership to Wine and is no longer maintained by Microsoft.
How can I determine what a package contains and whether it's stable and useful for my application?
The primary source for learning about a package is its listing page on nuget.org (or another private feed). Each package page on nuget.org includes a description of the package, its version history, and usage statistics. The Info section on the package page also contains a link to the project's web site where you typically find many examples and other documentation to help you learn how the package is used.
For more information, see Finding and choosing packages.
NuGet in Visual Studio
How is NuGet supported in different Visual Studio products?
- Visual Studio on Windows supports the Package Manager UI and the Package Manager Console.
- Visual Studio for Mac has built-in NuGet capabilities as described on Including a NuGet package in your project.
- Visual Studio Code (all platforms) does not have any direct NuGet integration. Use the NuGet CLI or the dotnet CLI.
- Azure DevOps provides a build step to restore NuGet packages. You can also host private NuGet package feeds on Azure DevOps.
How do I check the exact version of the NuGet tools that are installed?
In Visual Studio, use the Help > About Microsoft Visual Studio command and look at the version displayed next to NuGet Package Manager.
Alternatively, launch the Package Manager Console (Tools > NuGet Package Manager > Package Manager Console) and enter $host
to see information about NuGet including the version.
What programming languages are supported by NuGet?
NuGet generally works for .NET languages and is designed to bring .NET libraries into a project. Because it also supports MSBuild and Visual Studio automation in some project types, it also supports other projects and languages to various degrees.
The most recent version of NuGet supports C#, Visual Basic, F#, WiX, C++, and Q#.
What project templates are supported by NuGet?
NuGet has full support for a variety of project templates like Windows, Web, Cloud, SharePoint, Wix, and so on.
How do I update packages that are part of Visual Studio templates?
Go to the Updates tab in the Package Manager UI and select Update All, or use the Update-Package
command from the Package Manager Console.
To update the template itself, you need to manually update the template repository. See Xavier Decoster's blog on this subject. Note that this is done at your own risk, because manual updates might corrupt the template if the latest version of all dependencies are not compatible with each other.
Can I use NuGet outside of Visual Studio?
Yes, NuGet works directly from the command line. See the Install guide and the CLI reference.
NuGet command line
How do I get the latest version of NuGet command line tool?
See the Install guide. To check the current installed version of the tool, use nuget help
.
What is the license for nuget.exe?
You are allowed to redistribute nuget.exe under the terms of the MIT license. You are responsible for updating and servicing any copies of nuget.exe that you choose to redistribute.
Is it possible to extend the NuGet command line tool?
Yes, it's possible to add custom commands to nuget.exe
, as described in Rob Reynold's post available via Archive.org.
NuGet Package Manager Console (Visual Studio on Windows)
How do I get access to the DTE object in the Package Manager console?
The top-level object in the Visual Studio automation object model is called the DTE (Development Tools Environment) object. The console provides this through a variable named $DTE
. For more information, see Automation Model Overview in the Visual Studio Extensibility documentation.
I try to cast the $DTE variable to the type DTE2, but I get an error: Cannot convert the "EnvDTE.DTEClass" value of type "EnvDTE.DTEClass" to type "EnvDTE80.DTE2". What's wrong?
This is a known issue with how PowerShell interacts with a COM object. Try the following:
`$dte2 = Get-Interface $dte ([EnvDTE80.DTE2])`
Get-Interface
is a helper function added by the NuGet PowerShell host.
Creating and publishing packages
How do I list my package in a feed?
I have multiple versions of my library that target different versions of the .NET Framework. How do I build a single package that supports this?
How do I set up my own repository or feed?
See the Hosting packages overview.
How can I upload packages to my NuGet feed in bulk?
See Bulk publishing NuGet packages (jeffhandly.com).
Working with packages
Is it possible to install NuGet packages without Internet connectivity?
Yes, see Scott Hanselman's Blog post How to access NuGet when nuget.org is down (or you're on a plane) (hanselman.com).
How do I install packages in a different location from the default packages folder?
Set the repositoryPath
setting in Nuget.Config
using nuget config -set repositoryPath=<path>
.
How do I avoid adding the NuGet packages folder into to source control?
Set the disableSourceControlIntegration
in Nuget.Config
to true
. This key works at the solution level and hence need to be added to the $(Solutiondir)\.nuget\Nuget.Config
file. Enabling package restore from Visual Studio creates this file automatically.
How do I turn off package restore?
Why do I get an "Unable to resolve dependency error" when installing a local package with remote dependencies?
You need to select the All source when installing a local package into the project. This aggregates all the feeds instead of using just one. The reason this error appears is that users of a local repository often want to avoid accidentally installing a remote package due to corporate polices.
I have multiple projects in the same folder, how can I use separate packages.config files for each project?
In most projects where separate projects live in separate folders, this is not a problem as NuGet identifies the packages.config
files in each project. With NuGet 3.3+ and multiple projects in the same folder, you can insert the name of the project into the packages.config
filenames use the pattern packages.{project-name}.config
, and NuGet uses that file.
This is not an issue when using PackageReference, as each project file contains its own list of dependencies.
I don't see nuget.org in my list of repositories, how do I get it back?
- Add
https://api.nuget.org/v3/index.json
to your list of sources, or - Delete
%appdata%\.nuget\NuGet.Config
(Windows) or~/.nuget/NuGet/NuGet.Config
(Mac/Linux) and let NuGet re-create it.
I migrated to PackageReference, why is my build failing `This project references NuGet package(s) that are missing on this computer.`?
In packages.config projects, when a package with build
props or targets was installed, NuGet would add an EnsureNuGetPackageBuildImports
target to verify that the packages msbuild content has been imported before building.
If the target
has been modified manually, NuGet might not be able to detect that it needs removed when migrating.
If your project is PackageReference
and you still have this target in project file, it should be safe to remove.