使用SVN修订版在CCNET中标记构建

编程入门 行业动态 更新时间:2024-10-15 14:16:28
本文介绍了使用SVN修订版在CCNET中标记构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在以SVN作为源代码控件的示例项目上使用CCNET. CCNET被配置为在每次签入时都创建一个内部版本.CCNET使用MSBuild来构建源代码.

I am using CCNET on a sample project with SVN as my source control. CCNET is configured to create a build on every check in. CCNET uses MSBuild to build the source code.

我想在编译时使用最新的修订版号生成AssemblyInfo.cs. 如何从Subversion检索最新​​修订并在CCNET中使用该值?

I would like to use the latest revision number to generate AssemblyInfo.cs while compiling. How can I retrieve the latest revision from subversion and use the value in CCNET?

我不使用NAnt-仅使用MSBuild.

I'm not using NAnt - only MSBuild.

推荐答案

CruiseControl.Net 1.4.4现在具有程序集版本标签程序,它生成与.Net程序集属性兼容的版本号.

CruiseControl.Net 1.4.4 has now an Assembly Version Labeller, which generates version numbers compatible with .Net assembly properties.

在我的项目中,我将其配置为:

In my project I have it configured as:

<labeller type="assemblyVersionLabeller" incrementOnFailure="true" major="1" minor="2"/>

(注意:assemblyVersionLabeller在实际的提交触发的构建发生之前,不会开始生成基于svn修订版的标签.)

(Caveat: assemblyVersionLabeller won't start generating svn revision based labels until an actual commit-triggered build occurs.)

,然后通过 MSBuildCommunityTasks.AssemblyInfo 从我的MSBuild项目中使用:

and then consume this from my MSBuild projects with MSBuildCommunityTasks.AssemblyInfo :

<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/> <Target Name="BeforeBuild"> <AssemblyInfo Condition="'$(CCNetLabel)' != ''" CodeLanguage="CS" OutputFile="Properties\AssemblyInfo.cs" AssemblyTitle="MyTitle" AssemblyCompany="MyCompany" AssemblyProduct="MyProduct" AssemblyCopyright="Copyright © 2009" ComVisible="false" Guid="some-random-guid" AssemblyVersion="$(CCNetLabel)" AssemblyFileVersion="$(CCNetLabel)"/> </Target>

为了完整起见,对于使用NAnt而不是MSBuild的项目来说,这同样容易:

For sake of completness, it's just as easy for projects using NAnt instead of MSBuild:

<target name="setversion" description="Sets the version number to CruiseControl.Net label."> <script language="C#"> <references> <include name="System.dll" /> </references> <imports> <import namespace="System.Text.RegularExpressions" /> </imports> <code><![CDATA[ [TaskName("setversion-task")] public class SetVersionTask : Task { protected override void ExecuteTask() { StreamReader reader = new StreamReader(Project.Properties["filename"]); string contents = reader.ReadToEnd(); reader.Close(); string replacement = "[assembly: AssemblyVersion(\"" + Project.Properties["CCNetLabel"] + "\")]"; string newText = Regex.Replace(contents, @"\[assembly: AssemblyVersion\("".*""\)\]", replacement); StreamWriter writer = new StreamWriter(Project.Properties["filename"], false); writer.Write(newText); writer.Close(); } } ]]> </code> </script> <foreach item="File" property="filename"> <in> <items basedir=".."> <include name="**\AssemblyInfo.cs"></include> </items> </in> <do> <setversion-task /> </do> </foreach> </target>

更多推荐

使用SVN修订版在CCNET中标记构建

本文发布于:2023-11-06 20:37:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1564612.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:修订版   标记   SVN   CCNET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!