Use SVN revision to label build in ccnet

Source: Internet
Author: User

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:

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

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.