AssemblyInfo.cs应该放在版本控制中吗?

时间:2022-06-26 03:10:54

I have an automated build system using CruiseControl. I am using the SvnRevisionLabeller to 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.

我有一个使用CruiseControl的自动构建系统。我正在使用SvnRevisionLabeller来获取要使用的版本字符串。使用此字符串,我可以使用nant来更新AssemblyInfo.cs,因此在构建时它具有正确的构建字符串。我也可以使用此CC标签来标记subversion存储库。

So everything is aligned
- CCNet Build label
- Executable (Assembly Information)
- Version Control (subverson tag)

所以一切都是对齐的--CCNet Build标签 - 可执行(装配信息) - 版本控制(subverson标签)

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.

现在我遇到问题的是,如果我想尝试从存储库重建旧图像。由于AssemblyInfo.cs不受版本控制,而是生成文件,因此当我现在尝试构建时,版本信息将与使用CruiseControl构建此版本的存储库时的版本信息不同。我希望能够生成完全相同的图像,无论它是在CC构建期间构建还是在从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 a svn check-out the correct version information will be used?

我知道通常不建议这样做,但是我应该在每次构建之后签入assemblyInfo.cs文件,这样当我从svn签出后随后构建时,将使用正确的版本信息吗?

Thanks, Liam

4 个解决方案

#1


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 later so that builds made on developers workstations are easily extinguishable from the "official" ones downloaded from CruiseControl.Net).

或者根本不对AssemblyInfo.cs进行版本化,或者将它们的“开发者版本”放入存储库并让CruiseControl.Net在构建之后将它们还原(我之后会这样做,以便在开发人员工作站上进行的构建很容易从从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).

至于稍后再生相同的构建标签 - 您必须通过手动调用MSBuild / NAnt来进行重建,只需传递给它CCNetLabel设置为适当的值,您将获得与从CruiseControl调用的构建生成的相同的程序集版本.Net(MSBuild:/p:CCNetLabel=1.4.2.333,NAnt:-D:CCNetLabel = 1.4.2.333)。

#2


I use a CommonAssemblyInfo.cs file which I add a link to in every project.

我使用CommonAssemblyInfo.cs文件,我在每个项目中添加一个链接。

The only attribute I have in this file is AssemblyFileVersion and have CC.Net / Msbuild update the version every build.

我在这个文件中唯一的属性是AssemblyFileVersion,CC.Net / Msbuild每次构建都会更新版本。

Make sure any project that includes CommonAssemblyInfo.cs doesn't have duplicate attributes in AssemblyInfo.cs.

确保包含CommonAssemblyInfo.cs的任何项目在AssemblyInfo.cs中没有重复的属性。

If you check out the CC.Net source code you'll see that is how they have they're build configured.

如果您查看CC.Net源代码,您将看到他们是如何构建它们的。

#3


I always have it checked in. In fact I believe this is the default behavior with Team System Source Control.

我总是把它签入。实际上我相信这是Team System Source Control的默认行为。

#4


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).

我们有一个MSBuild脚本,可以在构建之前生成所有需要的AssemblyInfo.cs文件。这样我也可以在汇编版本中使用SVN版本号。 AssemblyInfo.cs文件不会被检入SVN(它们被忽略,因此它们不会打扰人们),而是在构建之前生成(无论是自动构建脚本还是来自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.

我还提供了一个批处理文件来处理AssemblyInfo.cs文件生成,这样开发人员就不需要为细节烦恼了。

#1


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 later so that builds made on developers workstations are easily extinguishable from the "official" ones downloaded from CruiseControl.Net).

或者根本不对AssemblyInfo.cs进行版本化,或者将它们的“开发者版本”放入存储库并让CruiseControl.Net在构建之后将它们还原(我之后会这样做,以便在开发人员工作站上进行的构建很容易从从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).

至于稍后再生相同的构建标签 - 您必须通过手动调用MSBuild / NAnt来进行重建,只需传递给它CCNetLabel设置为适当的值,您将获得与从CruiseControl调用的构建生成的相同的程序集版本.Net(MSBuild:/p:CCNetLabel=1.4.2.333,NAnt:-D:CCNetLabel = 1.4.2.333)。

#2


I use a CommonAssemblyInfo.cs file which I add a link to in every project.

我使用CommonAssemblyInfo.cs文件,我在每个项目中添加一个链接。

The only attribute I have in this file is AssemblyFileVersion and have CC.Net / Msbuild update the version every build.

我在这个文件中唯一的属性是AssemblyFileVersion,CC.Net / Msbuild每次构建都会更新版本。

Make sure any project that includes CommonAssemblyInfo.cs doesn't have duplicate attributes in AssemblyInfo.cs.

确保包含CommonAssemblyInfo.cs的任何项目在AssemblyInfo.cs中没有重复的属性。

If you check out the CC.Net source code you'll see that is how they have they're build configured.

如果您查看CC.Net源代码,您将看到他们是如何构建它们的。

#3


I always have it checked in. In fact I believe this is the default behavior with Team System Source Control.

我总是把它签入。实际上我相信这是Team System Source Control的默认行为。

#4


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).

我们有一个MSBuild脚本,可以在构建之前生成所有需要的AssemblyInfo.cs文件。这样我也可以在汇编版本中使用SVN版本号。 AssemblyInfo.cs文件不会被检入SVN(它们被忽略,因此它们不会打扰人们),而是在构建之前生成(无论是自动构建脚本还是来自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.

我还提供了一个批处理文件来处理AssemblyInfo.cs文件生成,这样开发人员就不需要为细节烦恼了。