简体   繁体   中英

Managing References in Visual Studio 2012

Please help me understand: I have a Visual Studio project. It has Nuget package manager enabled. I install several libraries. The library versions are shown in packages.config. Each library has a corresponding entry in References.

Now, say I want to change the library version from, say, 2.2.0 to 2.1.0. How I do this? At first I assumed you could just change the version number in packages.config. But when I do this, and get Nuget to download an earlier version of the library, the project references are not changed.

Do I have to manually remove each and every reference in the project to 2.2.0 and replace it with 2.1.0?

I get the feeling I'm "doing it wrong", but there doesn't seem to be any examples I can find of anyone doing it right.

Thanks for any help!

Using jQuery as an example:

If you want to rollback to a previous version you can run the Uninstall-Package jQuery and Install-Package jQuery -Version 2.1.0 commands from the package manager console.

Also, the package nuget page will have a list off all the versions available. EX: jQuery

All of this and more available in the nuget Docs

You can't simply change the version in the config file since your project still holds a reference to the binaries, so the binaries need to be replaced too.

Now, I'm not entirely sure if there is a "downgrade" Powershell command but you can certainly uninstall the specific package and then install a lower version. By using the Package Manager Console. So from within Visual Studio:

  1. Go to the View menu -> Other Windows -> Package Manager Console
  2. Select the Default Project from the dropdown list
  3. Then run the following command to uninstall the package

The command to uninstall is...

Uninstall-Package YOUR_PACKAGE_NAME

To install a lower version, run this command...

Install-Package YOUR_PACKAGE_NAME -Version 1.0

These and other commands are very well documented in The Package Manager Console Powershell Reference

Uninstall-Package Command

Install-Package Command

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM