NuSpec 版本属性与程序集版本 [英] NuSpec version attribute vs assembly version

查看:61
本文介绍了NuSpec 版本属性与程序集版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在创建nuget包时,nuget包文件名中的版本好像来自web应用项目中的AssemblyInfo文件.我还在 nuspec 文件中创建了一个版本属性.

When creating a nuget package, the version in the file name of the nuget package seems to come from the AssemblyInfo file in the web application project. I have also created a version attribute inside the nuspec file.

这两个版本号有什么关系,有什么约定吗?

What is the relationship between these two version numbers and are there any conventions attached?

推荐答案

关于约定,NuGet 软件本身以及它应用于库中的包的语义,按照如下所述进行版本控制SemVer.具体来说,您可以通过在您的 nuspec 版本号后加上-beta.4"或其他内容来指定 beta 版本.例如,查看图库如何显示最新版本的 AutoFac,并比较它的显示方式旧版本(注意文字这不是最新版本的Autofac 可用." 画廊似乎不再为非当前版本提供任何特殊信息)和 一个旧的预发布版本(带有文本这是 Autofac 的预发布版本.").

With regards to convention, the NuGet software itself, and the semantics it applies to packages in the gallery, does versioning as described by SemVer. Specifically you can designate beta versions by suffixing your nuspec version number with "-beta.4" or something. For example, see how the gallery displays the latest version of AutoFac, and compare how it displays an old release (note the text "This is not the latest version of Autofac available." The gallery no longer seems to provide any special message for non-current versions) and an old PRE-release version (with the text "This is a prerelease version of Autofac.").

遗憾的是,AssemblyInfo.cs 中的AssemblyVersion 可能不包含字母或连字符,因此不能以这种方式使用.但是,AssemblyInformationalVersion 中可能包含字母和连字符,如果您提供它,NuGet 将使用它代替 AssemblyVersion 来替换 $version$ 令牌在您的 nuspec 文件中.更重要的是,AssemblyInformationalVersion(如果您在 Windows 资源管理器中查看 DLL 的详细信息,也称为产品版本"),至少对我来说,更好地代表了 NuGet 版本应该匹配的内容.

Unfortunately, the AssemblyVersion in AssemblyInfo.cs may not contain letters or hyphens, so it can't be used in this way. However the AssemblyInformationalVersion MAY have letters and hyphens in it and, if you provide it, NuGet will use that instead of the AssemblyVersion to replace the $version$ token in your nuspec file. What's more, the AssemblyInformationalVersion (also called the "Product Version" if you check a DLL's details in windows explorer), at least to me, better represents what the NuGet version should match.

我对这种方法有点担心,因为我希望通过各种 beta 迭代和 AssemblyInformationalVersion 的最终生产迭代使 AssemblyVersion 保持不变,这意味着我允许我的 DLL 的几个不同版本进入野外,这些版本可能表现不同或不正确,但就 CLR 而言都是相同的(CLR 关心 AssemblyVersion).但在实践中,这种情况经常发生(包括上述 AutoFac 包),而且似乎不会引起问题.

I have a slight concern with this approach in that I'm expected to leave the AssemblyVersion the same through various beta iterations and a final production iteration of the AssemblyInformationalVersion, which means I'm allowing several different versions of my DLL into the wild that may behave differently or incorrectly, yet are all identical as far as the CLR is concerned (the CLR only cares about AssemblyVersion). In practice, though, this happens frequently (including with the AutoFac packages described above) and it doesn't seem to cause a problem.

请参阅AssemblyVersion、AssemblyFileVersion 和AssemblyInformationalVersion 之间有什么区别?,了解更多关于AssemblyInformationalVersion 和朋友们.

See the two excellent highest-voted answers to What are differences between AssemblyVersion, AssemblyFileVersion and AssemblyInformationalVersion? for more info on AssemblyInformationalVersion and friends.

这篇关于NuSpec 版本属性与程序集版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆