Specifying the version of a package to install with NuGet

NicolasBrondinBernard

Author
@NicolasBrondinBernard

Need a specific version of a package in C# with NuGet? Here's how to do it very simply!

Article published on 10/07/2023, last updated on 10/08/2026

NuGet, the dependency manager ("package manager") for .Net C# can be used directly in Visual Studio, or via the command line.

So we'll look at both possible solutions!

Here's how to specify the exact version of a package to ensure compatibility with your other dependencies and the version of .Net used in your project/solution.

Visual Studio (UI)

To display the NuGet dependency manager in Visual Studio:

  • Make sure your project isn't running (otherwise stop it)
  • Right-click on your project (or your solution) in the solution explorer
  • Click on "Manage NuGet Packages..."

Then to install the desired package:

  • Search for the name of the package to install and click on it
  • Select the desired package version in the right-hand panel
  • Click "Install"

Terminal (CLI)

Open the NuGet console by clicking on Tools > NuGet Package Manager > Package Manager Console

Then in the terminal that opens, all you need to do is:

Install-Package NUnit -Version 3.13.3

And there you go!

Changing the version of an already installed package

If the package is already installed in your project but you want to change its version, you can use the "Update-Package" command like this:

Update-Package NUnit -Version 3.13.3

Code (Manifest)

It's also possible to simply add a dependency manually in your project's XML manifest.

To open the manifest, double-click on your project's name in the solution explorer.

You'll then just need to find the list of dependencies in this file, and add your dependency in this form:

<PackageReference Include="NUnit" Version="3.13.3" />

Then you can restore your NuGet packages for the change to take effect:

  • Right-click on your solution
  • "Restore NuGet Packages"

Alessio Zappatore sur Unsplash

Finished reading this article?
Our newsletter

No spam. Only free content, news, and ever more resources to level up your skills!

Join +1500 developers

Comments (0)

to leave a comment

No comments yet