是否应该将 AssemblyInfo.cs 置于版本控制中?
我有一个使用 CruiseControl 的自动构建系统。 我正在使用 SvnRevisionLabeller 来获取要使用的版本字符串。 有了这个字符串,我可以使用 nant 更新 AssemblyInfo.cs,这样当我构建时它就有正确的构建字符串。 我还可以使用此 CC 标签来标记 subversion 存储库。
所以一切都是对齐的
- CCNet 构建标签
- 可执行文件(程序集信息)
- 版本控制(subverson 标签)
现在我遇到的问题是,如果我想尝试从存储库重建旧映像。 由于 AssemblyInfo.cs 不受版本控制,而是一个生成的文件,因此当我现在尝试构建时,版本控制信息将与使用 CruiseControl 构建此版本的存储库时的版本信息不同。 我希望能够生成完全相同的图像,无论它是在 CC 构建期间构建的还是稍后从 Subversion 签出时构建的。
我知道通常不建议这样做,但我是否应该在每次构建后签入 AssemblyInfo.cs 文件,以便当我随后从 svn 签出进行构建时,将使用正确的版本信息?
谢谢, 利亚姆
I have an automated build system using CruiseControl. I am using the SvnRevisionLabeller to get the version string to use. With this string I can use nant to update AssemblyInfo.cs so when I build it has the correct build string. I can also use this CC label to tag the subversion repository.
So everything is aligned
- CCNet Build label
- Executable (Assembly Information)
- Version Control (subverson tag)
Now where I have a problem is if I want to try to rebuild an old image from the repository. Since AssemblyInfo.cs is not under version control but rather a generated file, when I now try to build, the versioning information will not be the same as it was when this version of the repository was built using CruiseControl. I would like to be able to generate exactly the same image regardless of whether it was built during the CC build or at a later date when checking out from Subversion.
I know that it is often not recommended, but should I check-in the AssemblyInfo.cs file after each build so that when I build subsequently from an svn check-out the correct version information will be used?
Thanks,
Liam
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我使用 CommonAssemblyInfo.cs 文件,在每个项目中添加一个链接。
我在此文件中拥有的唯一属性是 AssemblyFileVersion,并且让 CC.Net / Msbuild 在每次构建时更新版本。
确保包含 CommonAssemblyInfo.cs 的任何项目在 AssemblyInfo.cs 中没有重复的属性。
如果您查看 CC.Net 源代码,您会发现这就是他们的构建配置方式。
I use a CommonAssemblyInfo.cs file which I add a link to in every project.
The only attribute I have in this file is AssemblyFileVersion and have CC.Net / Msbuild update the version every build.
Make sure any project that includes CommonAssemblyInfo.cs doesn't have duplicate attributes in AssemblyInfo.cs.
If you check out the CC.Net source code you'll see that is how they have they're build configured.
要么根本不对 AssemblyInfo.cs 进行版本控制,要么将它们的“开发人员版本”放入存储库中,并在构建后让 CruiseControl.Net svn-revert 它们(我选择后者,这样在开发人员工作站上进行的构建很容易与从 CruiseControl.Net 下载的“官方”版本)。
至于稍后复制相同的构建标签 - 您已经必须通过手动调用 MSBuild / NAnt 来进行重建,只需将 CCNetLabel 设置为适当的值传递给它,您将获得与从 CruiseControl 调用的构建相同的程序集版本.Net(MSBuild:
/p:CCNetLabel=1.4.2.333
,NAnt:-D:CCNetLabel=1.4.2.333
)。Either don't version AssemblyInfo.cs at all, or put "developer version" of them into the repository and have CruiseControl.Net svn-revert them after build (I do the latter so that builds made on developers workstations are easily distinguishable from the "official" ones downloaded from CruiseControl.Net).
As for reproducing the same build labels later - you already have to do the rebuild by calling MSBuild / NAnt by hand, simply pass to it CCNetLabel set to appropriate value and you'll get the same assembly versions generated as with the build invoked from CruiseControl.Net (MSBuild:
/p:CCNetLabel=1.4.2.333
, NAnt:-D:CCNetLabel=1.4.2.333
).我总是将其签入。事实上,我相信这是 Team System Source Control 的默认行为。
I always have it checked in. In fact I believe this is the default behavior with Team System Source Control.
我们有一个 MSBuild 脚本,可在构建之前生成所有所需的 AssemblyInfo.cs 文件。 这样我也可以在程序集版本中使用 SVN 修订号。 AssemblyInfo.cs 文件不会检入 SVN(它们会被忽略,这样就不会打扰人们),而是在构建之前生成(无论它是自动构建脚本还是来自 VS)。
我还提供了一个批处理文件来处理 AssemblyInfo.cs 文件的生成,以便开发人员无需担心细节。
We have a MSBuild script that generates all the needed AssemblyInfo.cs files prior to the build. This way I can also use the SVN revision number in the assembly versions. The AssemblyInfo.cs files are not checked into SVN (they're ignored so that they don't bother people) but generated prior to building (doesn't matter whether it an automated build script or from VS).
I also supply a batch file to take care of the AssemblyInfo.cs files generation so that the developers don't need to bother with the details.