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.
How to get a list of updated packages
- Open your .NET MAUI app folder on Visual Studio Code. The .NET MAUI extension will automatically load your solution with the referenced projects.
- Once Visual Studio Code loaded your project's solution successfully on the Solution Explorer.
- Open the Visual Studio Code integrated terminal and run the following command:
dotnet outdated
- 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).
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.
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:
<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
- LinkedIn victorhugogarcia
- Threads @ihugo
- X @ivictorhugo
Top comments (0)