简体   繁体   English

重命名 NuGet Package ID 后如何定义后继 package ID

[英]How to define the successor package ID after a rename of the NuGet Package ID

I know, you should not change the Package ID of a NuGet Package.我知道,您不应该更改 NuGet Package 的 Package ID。 But I did, because of a big refactoring.但我做到了,因为进行了一次大的重构。

Now I want to know if there is a proper way to define a successor NuGet package.现在我想知道是否有合适的方法来定义后继 NuGet package。

Old ID in Nuspec: OldLibrary1 Nuspec 中的旧 ID: OldLibrary1
New ID in Nuspec/csproj file: Library1 Nuspec/csproj 文件中的新 ID: Library1

If a user opens the NuGet Package Management window for a Visual Studio Solution and the old package (ID OldLibrary1-1.0.0 ) is installed, he should see an update/upgrade to package Library1-2.0.0 . If a user opens the NuGet Package Management window for a Visual Studio Solution and the old package (ID OldLibrary1-1.0.0 ) is installed, he should see an update/upgrade to package Library1-2.0.0 .

Is there a possible way to define this in some way?有没有可能以某种方式定义它?

By the way I use ProGet as NuGet server.顺便说一句,我使用 ProGet 作为 NuGet 服务器。

NuGet recently added deprecation information to it's HTTP protocol, however, as far as I know, only nuget.org has implemented it (it's very new, NuGet 5.3, Visual Studio 16.3). NuGet recently added deprecation information to it's HTTP protocol, however, as far as I know, only nuget.org has implemented it (it's very new, NuGet 5.3, Visual Studio 16.3). If your private nuget server (Proget) hasn't implemented it yet, you can try contacting the developers and ask them to implement it.如果您的私有 nuget 服务器(Proget)还没有实现它,您可以尝试联系开发人员并要求他们实现它。

Otherwise the best option I've heard about is to create a new version of your old library, do not include any assemblies in it, just have a NuGet dependency on your new package id.否则,我听说的最佳选择是创建旧库的新版本,不要在其中包含任何程序集,只需 NuGet 依赖于新的 package id。

The issue with this is if your package consumer is using PackageReference , Visual Studio's upgrade experience isn't yet great, because when you release a new version of your new package, people getting it as a transitive dependency of your old package won't be notified about the available upgrade. The issue with this is if your package consumer is using PackageReference , Visual Studio's upgrade experience isn't yet great, because when you release a new version of your new package, people getting it as a transitive dependency of your old package won't be通知可用的升级。 An option to work around this is to include a MSBuild targets file which displays a build warning on every build, telling them to install the new package and uninstall the old package.解决此问题的一个选项是包含一个 MSBuild 目标文件,该文件在每个构建上显示构建警告,告诉他们安装新的 package 并卸载旧的 package。 People who ignore warnings won't see it, so if you want to be extreme, make it an error instead, but it helps get the message out.忽略警告的人不会看到它,所以如果你想变得极端,那就让它成为一个错误,但这有助于传达信息。

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

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