增加每个构建中的装配版本?

huangapple go评论74阅读模式
英文:

Increasing Assembly revision in Every build?

问题

几天前,我访问了一个开发团队相对较小的公司。

他们使用VS2019,主要开发Web表单应用程序。我发现他们在每次构建中递增程序集和文件版本修订号的策略有些值得质疑。

即使没有进行任何更改,他们也会在每次构建时增加修订号(他们在Assemblyinfo.cs中用 * 表示修订号)。

我想知道上述的做法是否会引起任何问题?例如,我记得旧版本的VS对修订号有数量限制。

英文:

A few days back I visited a company with a fairly small dev team.

They Use VS2019 and mostly Web Form Apps. I found their policy of increasing Assembly and
file versions revision by one on every single build questionable.

Even if nothing is changed they increase the revision on every build.(they put a * for revision in Assemblyinfo.cs)

I want to know if the above procedure can cause any issues whatsoever? For example I remember the old versions of VS had a limit for the number of revision.

答案1

得分: 2

此确切情况实际上在Visual Studio文档中有解释:

// 一个程序集的版本信息包括以下四个值:
// 主版本号
// 次版本号
// 版本号
// 修订号
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

在绝对数字的位置上提供 (*) 会使编译器在每次构建时增加一个数字。

假设您正在为项目构建一个框架程序集,该程序集由许多开发人员在构建应用程序程序集时使用。如果您经常发布程序集的新版本,比如每天发布一次,并且程序集具有强名称,那么开发人员每次发布新程序集时都必须更改引用。这可能很繁琐,可能导致引用错误。在这种封闭组和不稳定的情况下,更好的选择是固定 AssemblyVersion 并仅更改 AssemblyFileVersion。使用程序集文件版本号来传达程序集的最新发布版本。在这种情况下,开发人员不必更改引用,并且可以覆盖引用路径中的程序集。在中央或最终发布版本构建中,更改 AssemblyVersion 并保持 AssemblyFileVersion 与程序集版本相同是更有意义的。

英文:

This exact scenario is actually addressed in the Visual Studio docs

>cs
>// Version information for an assembly consists of the following four values:
>// Major Version
>// Minor Version
>// Build Number
>// Revision
>[assembly: AssemblyVersion("1.0.0.0")]
>[assembly: AssemblyFileVersion("1.0.0.0")]
>

>Providing a (*) in place of absolute number makes compiler increase the number by one every time you build.
>
>Suppose you're building a framework assembly for your project that is used by lot of developers while building the application assemblies. If you release new version of assembly frequently, say once every day, and if assemblies are strong named, Developers will have to change the reference every time you release new assembly. It can be cumbersome and may lead to wrong references also. A better option in such closed group and volatile scenarios would be to fix the AssemblyVersion and change only the AssemblyFileVersion. Use the assembly file version number to communicate the latest release of assembly. In this case, developers won't have to change the references and they can overwrite the assembly in reference path. In central or final release builds it makes more sense to change the AssemblyVersion and most keep the AssemblyFileVersion same as assembly version.

huangapple
  • 本文由 发表于 2023年6月29日 00:36:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76575136.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定