简体   繁体   中英

VS2010 Update Nuget package to a specific version, but also update dll References in projects

For example my solution uses Nuget package "foo" with version "1.2.30". I want to Update "foo" package for all my solution projects to version "1.2.25", for example. I can't do it through Visual Studio Nuget addon, because if I right click on solution -> Manage packages -> Updates, Nuget won't propose me to update to the version that I want. Nuget will propose only the latest version.

So, I'm using workaround like this:

  1. Manually change "packages.config" files for all projects that use this package from "1.2.30" to "1.2.25" package version.
  2. Right click on solution and Restore packages (Nuget will download "foo" v1.2.25).
  3. After that I need to update References in all projects that use this package, because they still reference "1.2.30". So I open every project "References", Remove the "foo" dll reference(v1.2.30) and then click Add and add dll reference "foo"(v1.2.25).

Questions:

  1. Nuget VS2010 addon is so awesome, why doesn't it have "update to specific version" option in Visual Studio 2010 ?
  2. Is there any other easier steps to do what I want ?

Thanks a lot, that's really bugging me.

========== ANSWER: ==========

You can use Package Manager Console(Tools -> Nuget Package Manager -> Package Manager Console) in Visual Studio to command Nuget what to do via console. It is much more flexible than "Manage Nuget packages".

Examples: Update package "foo" only for project "MyProject":

Update-Package -Id foo -Version 1.2.25 -ProjectName MyProject -IncludePrerelease

Update package "foo" for all projects in solution:

Update-Package -Id foo -Version 1.2.25 -IncludePrerelease

Full help can be found here:

http://docs.nuget.org/docs/reference/package-manager-console-powershell-reference

You should be able to do this from the Package Manager Console. The following should update all NUnit NuGet packages to version 2.6.1 which is not the latest version.

Update-Package NUnit -version 2.6.1

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