简体   繁体   English

VS2010将Nuget软件包更新为特定版本,但也更新了项目中的dll引用

[英]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". 例如,我的解决方案使用版本为“ 1.2.30”的Nuget软件包“ foo”。 I want to Update "foo" package for all my solution projects to version "1.2.25", for example. 例如,我想将我所有解决方案项目的“ foo”包更新为版本“ 1.2.25”。 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. 我无法通过Visual Studio Nuget插件执行此操作,因为如果我右键单击解决方案->管理软件包->更新,Nuget不会建议我将其更新为所需的版本。 Nuget will propose only the latest version. Nuget将仅提出最新版本。

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. 手动将使用此软件包的所有项目的“ packages.config”文件从“ 1.2.30”更改为“ 1.2.25”软件包版本。
  2. Right click on solution and Restore packages (Nuget will download "foo" v1.2.25). 右键单击解决方案并还原软件包(Nuget将下载“ 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". 之后,我需要在所有使用此程序包的项目中更新“引用”,因为它们仍引用“ 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). 因此,我打开了每个项目“ References”,删除了“ foo” dll参考(v1.2.30),然后单击“添加”并添加dll参考“ 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 ? Nuget VS2010插件非常棒,为什么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. 您可以在Visual Studio中使用程序包管理器控制台(工具-> Nuget程序包管理器->程序包管理器控制台)命令Nuget通过控制台执行操作。 It is much more flexible than "Manage Nuget packages". 它比“管理Nuget软件包”要灵活得多。

Examples: Update package "foo" only for project "MyProject": 示例:仅针对项目“ MyProject”更新软件包“ foo”:

Update-Package -Id foo -Version 1.2.25 -ProjectName MyProject -IncludePrerelease 更新包-Id foo-版本1.2.25 -ProjectName MyProject -IncludePrerelease

Update package "foo" for all projects in solution: 更新解决方案中所有项目的软件包“ foo”:

Update-Package -Id foo -Version 1.2.25 -IncludePrerelease 更新包-Id foo-版本1.2.25 -IncludePrerelease

Full help can be found here: 完整的帮助可以在这里找到:

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

You should be able to do this from the Package Manager Console. 您应该能够从Package Manager控制台执行此操作。 The following should update all NUnit NuGet packages to version 2.6.1 which is not the latest version. 以下应该将所有NUnit NuGet软件包更新到版本2.6.1,这不是最新版本。

Update-Package NUnit -version 2.6.1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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