How do I Update a Nuget Package using dotnet CLI

Date Published: 25 May 2017

How do I Update a Nuget Package using dotnet CLI

The current version of the dotnet command line interface provides features to add a nuget package, but doesn’t expose a separate command to update them. However, you can actually achieve this by simply running the dotnet add package command, for example:

dotnet add package Microsoft.AspNetCore

If you don’t provide a version flag, this will default to upgrading to the latest version. To specify a version, add the -v parameter:

dotnet add package Microsoft.AspNetCore -v 1.0.2

Here you can see a sample project with an older version of AspNetCore shown in Visual Studio’s Nuget Package Manager:

nuget updates available

Run the command in Powershell:

dotnet add package

The result is the updated version in the project.

nuget installed packages

Currently there isn’t a command to browse, search, or list packages from the dotnet CLI. However, this is coming in version 2.0.

Steve Smith

About Ardalis

Software Architect

Steve is an experienced software architect and trainer, focusing on code quality and Domain-Driven Design with .NET.


Ardalis

Copyright © 2021