简体   繁体   English

如何强制包管理器更新具有相同版本的Nuget包?

[英]How to force the Package Manager to Update a Nuget package with the same version?

How can Update be enabled even though the version number has not changed? 即使版本号未更改,如何启用更新?

I'm developing a Nuget package. 我正在开发一个Nuget包。 We're in the early stages, beta/testing. 我们处于早期阶段,测试/测试。 We don't change the version until testing is complete but we want to pass on the changed package for testing purposes. 我们不会在测试完成之前更改版本,但我们希望传递更改的包以进行测试。 But the Package Manager does not see the change, allow Update, unless the version has changed, I can reinstall but I'd prefer the testers to be able to Update. 但是包管理器看不到更改,允许更新,除非版本已更改,我可以重新安装,但我更希望测试人员能够更新。

How can this be done while the version number stays the same? 如何在版本号保持不变的情况下完成此操作?

Resurrecting this as we are in the same boat (converting a monolithic solution to a Nuget-ified microservices architecture). 恢复这一点,因为我们在同一条船上(将单片解决方案转换为Nuget-ified微服务架构)。 This method works, though its a bit tedious: 这种方法有效,但有点单调乏味:

Go to NuGet options and click 'Clear All NuGet Cache(s)' Do a Nuget package restore on the solution. 转到NuGet选项并单击“清除所有NuGet缓存”对解决方案执行Nuget包还原。 If this ends up failing due to (eg Newtonsoft.json being 'in use by another process') close all instances of Visual Studio & end task on all instances of MSBuild.exe + VBCSCompiler.exe. 如果由于(例如,Newtonsoft.json'正在被另一个进程使用'而失败),请关闭所有MSBuild.exe + VBCSCompiler.exe实例上的所有Visual Studio实例并结束任务。 Restart VS and it should work. 重新启动VS,它应该工作。

Note that removing and re-adding the package will not work as it will still use the old cached version. 请注意,删除和重新添加程序包将无法正常工作,因为它仍将使用旧的缓存版本。

I just faced the same problem and my search brought me to here. 我刚遇到同样的问题,我的搜索把我带到了这里。

Normally we are using the AssemblyInformationalVersion field to specify prerelease suffixes, eg: 通常我们使用AssemblyInformationalVersion字段来指定预发布后缀,例如:

  • 0.9.5-beta00001 0.9.5-beta00001
  • 0.9.5-beta00002 0.9.5-beta00002
  • ... ...

When enabling prerelease versions in the NuGet package manager, these packages are offered as well. 在NuGet包管理器中启用预发布版本时,也会提供这些包。 As long as the suffix expression "increases", the package manager treats subsequent prerelease versions as update. 只要后缀表达式“增加”,包管理器就会将后续预发布版本视为更新。 It's important therefore to start with a well-thought suffix, as eg the following will not work: beta9 > beta10 ( beta9 is treated higher, as the fifth character is higher). 因此,重要的是从一个经过深思熟虑的后缀开始,例如以下内容将不起作用: beta9 > beta10beta9被处理得更高,因为第五个字符更高)。

As soon as the suffix is removed, the package is treated as release and is offered as update to all prerelease packages of the same version. 删除后缀后,包将被视为发行版,并作为更新提供给同一版本的所有预发布包。

But as life gambles with us, sometimes we identify a small bug or improvement in a just released library. 但随着生活与我们一起赌博,有时我们会发现一个小错误或刚刚发布的库中的改进。 It's always really annoying to increase the version number again for such a microchange, if the just released library even wasn't used anywhere, cause its release is minutes ago only. 如果刚刚发布的库甚至没有在任何地方使用过,那么再次为这样的微变量增加版本号总是很烦人,因为它只在几分钟之前发布。

For this case I tried the procedure outlined by Simon Storr, but it wasn't enough. 对于这种情况,我尝试了Simon Storr概述的程序,但这还不够。 I encountered the old version in the packages directory of our solution. 我在解决方案的packages目录中遇到了旧版本。 After manually deleting it from there, it took the current package from somewhere. 从那里手动删除后,它从某处获取当前包。 I am not sure if it downloaded the current package at this step, or took it from a more global packages directory that is located in the parent directory of the solution. 我不确定它是在此步骤下载了当前包,还是从位于解决方案父目录中的更全局包目录中获取。

Note that there are multiple packages directories! 请注意,有多个包目录! The properties of the NuGet package in the Visual Studio references view of the project displayed the global packages directory only. 项目的Visual Studio参考视图中的NuGet包的属性仅显示全局包目录。 But there was the new version already (checked this with ILSpy), while still the old version was copied to the bin directory. 但是已经有新版本(用ILSpy检查过),而旧版本仍然被复制到bin目录。

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

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