.NET MAUI: Update NuGet Packages using Visual Studio Code
Tags: dotnet, dotnetmaui, vscode, nuget
Published: 2024-01-29 19:48:08

In this post, I will show you how to use Visual Studio Code in macOS, a popular and lightweight code editor, to search for your outdated NuGet packages of your project with ease and update those faster using the terminal and updating a couple of bits on your _.csproj_ file.

### Requirements
It is required for you to install the official .NET MAUI extension in Visual Studio Code and the dotnet-outdated tool.
- [.NET MAUI extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.dotnet-maui)
- [dotnet-outdated tool](https://github.com/dotnet-outdated/dotnet-outdated)

### How to get a list of updated packages

1. Open your .NET MAUI app folder on Visual Studio Code. The .NET MAUI extension will automatically load your solution with the referenced projects.
2. Once Visual Studio Code loaded your project's solution successfully on the **Solution Explorer**.
3. Open the Visual Studio Code integrated terminal and run the following command:
`dotnet outdated`
4. The previous command will parse and show you a list of NuGet packages where an updated version exists based on your current project installed packages _(see image below for further details)_.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dd4jpsolfz26swlr51zx.png)

> On the image above, it lists not only a specific project but any other project in the solution, and broken down into platforms, so it is easy to identify which NuGet packages being used on your project offer a new updated version.
```xml
Version color legend:
<red>   : Major version update or pre-release version. Possible breaking changes.
<yellow>: Minor version update. Backwards-compatible features added.
<green> : Patch version update. Backwards-compatible bug fixes.
```

### How to update your project's NuGet packages
It is super easy, just open your _.csproj_ file and find the Package References, for example:

```xml
<ItemGroup>
	  <PackageReference Include="Microsoft.Maui.Controls" Version="8.0.6" />
  	  <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.6" />
</ItemGroup>
```

Then update the key-value from Version and set the new version retrieved previously by using the command on the terminal.

Finally, once all your NuGet package references are updated as your requirements, I recommend you to close Visual Studio Code and re-open it, so the extension reloads again the solution and projects. As a verification method to make sure your packages are up to date, run the command `dotnet outdated` again, so you get an updated list.

That's it!

### Conclusion
In Visual Studio Code, I have tried some NuGet Managament extensions without luck, due to the nature of .NET MAUI being cross-platform, the current existing extensions do not support it, that is the main reason of me writing this article. 
I heard somewhere that the Microsoft team is working on extension/feature that will make the NuGet Management easily on projects using Visual Studio Code, so hopefully we can see a preview in the coming months.

Updating NuGet packages is important to keep our projects up to date with the latest features and bug/security fixes. 



Thank you for reading!

Follow me on Social:
- GitHub **[@vhugogarcia](https://github.com/vhugogarcia)**
- LinkedIn **[victorhugogarcia](https://www.linkedin.com/in/victorhugogarcia/)**
- Threads  **[@ihugo](https://www.threads.net/@ihugo)**
- X **[@ivictorhugo](https://twitter.com/ivictorhugo)**