When creating and maintaining (.NET Core) applications, it is always a good idea to keep the dependencies up-to-date. This helps to fix identified vulnerabilities but also keeps the upgrade path short as you closely stay to the latest package version. In this post I show you 3 ways to identify outdated packages and update them when necessary.
Through the Visual Studio Package Manager
When using Visual Studio, it is easy to find out whether newer versions of the NuGet packages used by your project is available, by using the NuGet Package Manager:
- Open your solution/project in Visual Studio
- Go to Tools-> NuGet Package Manager –> Manage NuGet Packages for Solution…
- Go to the Updates tab, check the Select all packages checkbox and click on Update
Through the dotnet-outdated global tool
A second option is to use the open source global .NET tool: dotnet-outdated.
- First install the tool using the following command:
dotnet tool install --global dotnet-outdated-tool
- Now you can call the tool using the following command:
dotnet-outdated
- To update the outdated packages run this command:
dotnet-outdated --upgrade
Through the .NET Core CLI
A last option is to use the .NET Core CLI directly.
- To get the list of outdated packages, run the following command:
dotnet list package --outdated
- Now if we want to update an outdated package, you can do the following:
dotnet add package PACKAGENAME
Remark: We have to repeat this command for every package that requires an update.