TeamCity的装配版本控制 [英] Assembly Versioning with TeamCity

查看:75
本文介绍了TeamCity的装配版本控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个使用SVN和TeamCity构建服务器的C#/ VB.Net项目。该版本生成了十几个程序集。我想控制程序集的版本,以便它们都匹配并且也匹配TeamCity的构建标签。

I'm working on a C#/VB.Net project that uses SVN and TeamCity build server. A dozen or so assemblies are produced by the build. I want to control the assembly versions so that they all match up and also match the TeamCity build label.

我已将TeamCity配置为使用

I've configured TeamCity to use a build label of


Major.Minor。{Build}。{Revision}

Major.Minor.{Build}.{Revision}

其中Major和Minor是我手动设置的常量,{Revision}由结帐时的SVN存储库版本确定,而{Build}是TeamCity自动递增的构建计数器。因此,示例构建标签将是

Where Major and Minor are constants that I set manually, {Revision} is determined by the SVN repository version at checkout and {Build} is a TeamCity auto-incrementing build counter. So an example build label would be


2.5.437.4423

2.5.437.4423

您将建议什么技术来确保所有程序集版本都与TeamCity构建标签匹配?

What techniques would you suggest to ensure that all of the assembly versions match the TeamCity build label?

推荐答案

我们正在使用CruiseControl.net和SVN。我们以其他方式驾驶它。我们在MSBuild脚本中使用 MSBuildCommunityTasks 版本任务来增加CI版本的版本号并使用该版本标记源代码的编号。

We're using CruiseControl.net and SVN. We drive it the other way. We are using the MSBuildCommunityTasks Version task in an MSBuild script to increment the version number for CI builds and using that version number to tag the source code.

编辑:询问有关MSBuild目标的更多详细信息...

我们使用一个单独的脚本CI版本,不用于开发人员版本。我们尝试在Studio用作项目文件的MSBuild文件中使用不同的目标,但这令人头疼,需要手动编辑Studio生成的文件。

MSBuild文件的结构非常简单:

Asked for more detail on MSBuild targets...
We use a separate script that is for the CI build and is not used for the developer builds. We tried using different targets in the MSBuild files that studio uses as project files but this got to be a headache and required manual editing of files that studio was generating.
The structure of the MSBuild file is pretty straightforward:


  1. 导入多余的物品

  1. Import extra pieces

< ; Import Project = $(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets />

<!-包含一些用于设置项目名称,路径等的变量。->

<导入Project = Properties.msbuild />

BeforeBuild:设置新版本号并重写AssemblyInfo文件

BeforeBuild: set new version number and rewrite the AssemblyInfo file

<版本VersionFile = $(VersionFile) BuildType = None RevisionType = Increment>

<输出TaskParameter = Major PropertyName = Major />

< Output TaskParameter = Minor PropertyName = Minor />

<输出TaskParameter = Build PropertyName = Build />

< Output TaskParameter = Revision PropertyName =修订 />

< / Version>

<!-修改程序集信息->

< AssemblyInfo CodeLanguage = CS

OutputFile = Properties\AssemblyInfo.cs

AssemblyTitle = $(TargetAssembly)

AssemblyDescription = $(AssemblyDescription)svn:@(SanitizedSvnUrl)版本:$(SvnRevision)

AssemblyCompany =您的公司名称

AssemblyProduct =名称产品

AssemblyCopyright =版权所有©您的公司2009

ComVisible = false Guid = $(WindowGuid)

AssemblyVersion = $(Major)。$(Minor)。$(Build )。$(修订)

AssemblyFileVersion = $(主要)。$(未成年人)。$(内部版本)。$(修订)

Condition = $(Revi sion)!='0' />

<!--Modify Assembly Info-->
<AssemblyInfo CodeLanguage="CS"
OutputFile="Properties\AssemblyInfo.cs"
AssemblyTitle="$(TargetAssembly)"
AssemblyDescription="$(AssemblyDescription) svn:@(SanitizedSvnUrl) revision:$(SvnRevision)"
AssemblyCompany="Your company name"
AssemblyProduct="Name of product"
AssemblyCopyright="Copyright © your company 2009"
ComVisible="false" Guid="$(WindowGuid)"
AssemblyVersion="$(Major).$(Minor).$(Build).$(Revision)"
AssemblyFileVersion="$(Major).$(Minor).$(Build).$(Revision)"
Condition="$(Revision) != '0' " />

构建:以发布模式构建实际的项目文件MSBuild脚本

Build: build the actual project file MSBuild script in release mode

AfterBuild:我们运行单元测试项目(以防止在后续步骤中为损坏的版本创建标签),使用SvnInfo任务和一些RegexReplace任务进行设置一些带有路径和标签名称的变量,并使用SvnCopy任务创建标签。

AfterBuild: we run our unit test projects (as a guard against creating tags for broken builds in the next steps), use the SvnInfo tasks and some RegexReplace tasks to set some variables up with paths and tag names, and use the SvnCopy task to create the tag.

< SvnCopy UserName = username

Password =密码

SourcePath = @(SvnTrunkPath)

DestinationPath = @(SvnTagsPath)/ BUILD-$(TargetAssembly)-$(Major)。$(Minor)。$(Build)。$(Revision)
Message =标记成功构建 />

这篇关于TeamCity的装配版本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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