Monday, March 12, 2018

Package Management in .NET Core

When developing .NET applications, developers use Nuget, Visual Studio and PowerShell. But what about .NET Core?
 Photo by Christian Wiediger on Unsplash 

In development, it's common to import and reuse routines from external libraries. That code is often code is bundled into packages/libraries that could contain compiled code (as DLLs) along with other content needed in the projects that consume these packages (CSS, images, JavaScript, etc).

If you use .NET you have already dealt with Nuget one way or another. But how does that work in .NET Core?

Nuget and .Net Core

Nuget remains strong in .Net Core as it's the default tool to download packages. For more info regarding Nuget, please visit:

If you have Visual Studio installed in your machine, probably already have nuget.exe installed because it already contains a built in Nuget package manager which does not mean that nuget.exe is installed on your machine.

With .Net Core, package maintance is done using the new dotnet cmdlet.


For .NET, the Microsoft-supported mechanism for sharing code is NuGet, which defines how packages for .NET are created, hosted, and consumed, and provides the tools for each of those roles. is where most of these packages (free or not) are hosted and can be downloaded. Also note that you also can host your own nuget server containing your team's internal packages.

Managing Nuget Packages

In order to build, push, modify and manage nuget packages, we need to use the nuget.exe tool. If you're interested in managing your own packages, please take a look at this documentation.

Installing nuget.exe

As nuget.exe itself is not included with any version of Visual Studio, if you want to use it, you can then go and download it on Please download the latest.

Also, don't forget to set it on your %path% so it's accessible from the command prompt everywhere.

Nuget Package Exlorer

I also recommend installing Nuget Package Explorer for a friendly nuget.exe user interface.

The Global Packages Folder

After Nuget3, there is now a packages folder that is shared for all projects that you work with. Packages are downloaded and stored in the %userprofile%\.nuget\packages folder so you will only have one copy of that package on your machine. The same package can be reused for new projects saving time and band, especially on build servers.

The following command line lists you all packages installed in your system, for your user:
nuget locals global-packages -list

Adding nuget packages to your .Net Core project

Adding packages a your solution can be done two ways: by using Visual studio or from the command line.

Adding using the command line:

Using .Net Core, in the project folder, run the following command:
dotnet add package <package-name>

Adding packages using Visual Studio:

Adding with VS is simply right-clicking the web project name -> Manage NuGet packages:

Restoring packages

The dotnet restore command restores the dependencies and tools of a project But you don't need to run it after adding a new package because it's implicitly run by all commands, such as dotnet build and dotnet run.

In your solution folder, run:
dotnet restore
For more info, visit:


With access to command line tools it is way easier to write scripts, automate, manipulate multiple packages at once just by using the command line. Being a very important to know due to the, I usually urge .Net developers to read more about it. For more information on command line reference, visit:

Still on Nuget packages, also spend some time understanding how they are built and shared. May be a good fit for your project.

See Also


For more posts on .NET Core, please click here.
Do you have any comment or suggestion about this post? Please contact me @BrunoHilden