Navigation

Search

Categories

 

On this page

[Build Knowledge] Versioning
Where's all the posts?
Google Reader Minimalistic

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 8
This Year: 2
This Month: 0
This Week: 0
Comments: 6

Sign In
Pick a theme:

 Saturday, November 17, 2007
Saturday, November 17, 2007 7:13:28 PM (GMT Standard Time, UTC+00:00) ( )

Today I’ll show you how to use NAnt and Cruise Control.Net to Version your application.

What you’ll need

  1. NAnt A .Net Build tool. We’re going to use this to compile our Hello World Application and set the version number.
  2. Cruise Control.Net A Continious Integration Server that lets us start NAnt and makes our version number.

Our Application

Theres nothing much to our application it just shows the Assembly Version at command line.

using System;
using System.Reflection;

namespace BuildKnowledge.CmdLine
{
  class Program
  {
    static void Main(string[] args)
    {
      Console.Out.WriteLine("Hello World v" + Assembly.GetExecutingAssembly().GetName(false).Version);
    }
  }
}

NAnt Build file

Lets look at the build file

<?xml version="1.0" encoding="utf-8"?>
<project name="BuildKnowledge" default="compile"

  <target name="init">
    <delete dir="build"
/>
    <
mkdir dir="build"
/>
  </
target
>

  <target name="asminfo">
   
<if test="${property::exists('CCNetLabel') == false}">
     
<
property name="CCNetLabel" value="1.0.0.1" />
   
</
if>
   
<
asminfo output="build\AssemblyInfo.cs" language="CSharp">
     
<
imports>
       
<
import namespace="System" />
        <
import namespace="System.Reflection" />
        <
import namespace="System.EnterpriseServices" />
        <
import namespace="System.Runtime.InteropServices" />
      </
imports>
      <attributes>
        <attribute type="AssemblyVersionAttribute" value="${CCNetLabel}" />
        <
attribute type="AssemblyTitleAttribute" value="Build knowledge - Hello World" />
        <
attribute type="ApplicationNameAttribute" value="BuildKnowledge" />
      </
attributes>
      <
references>
        <
include name="System.EnterpriseServices.dll" />
      </
references>
    </
asminfo>
  </
target>

  <target name="compile" depends="init,asminfo">
    <
csc output="build\${project::get-name()}.exe" target="exe" debug="false">
      <
sources basedir="src">
        <
include name="**/*.cs" />
        <
include name="../build/AssemblyInfo.cs" />
        <
exclude name="**/AssemblyInfo.cs" />
      </
sources>
    </
csc>
  </
target>

</project>

This is the BuildKnowledge.build file that will run our build. Here’s the steps we’re taking

  • [init] Create a directory called build
  • [asminfo] Generate the AssemblyInfo.cs
  • [compile] Compile BuildKnowledge.exe

The important thing to see is CCNetLabel which is a property that CCNet is going to send down to the NAnt task. This is called an Integration Property and there are additional properties for things like the build time just check the list.

Cruise Control .Net Configuration

Once you’ve installed cruise control you’ll want to update ccnet.config to add this project. You’ll need to update the nant task with the correct paths to where your files are located. In an actual setting we’d actually have a sourcecontrol block that automatically triggers the build and updates the working copy on the build server. For now we’ll just trigger the build manually which isn’t truely Continious Integration but it’ll work for this example. The Labeller Block is where we come up with the version number for the assembly and it will show up on Cruise Control.Net and it will be sent down to NAnt.

<cruisecontrol>
  <
project name="BuildKnowledge Current">
    <
tasks>
      <
nant>
        <
executable>C:\nant\bin\NAnt.exe</executable>
        <
baseDirectory>C:\code\BuildKnowledge</baseDirectory>
        <
nologo>false</nologo>
        <
buildFile>buildknowledge.build</buildFile>
        <
targetList>
          <
target>compile</target>
        </
targetList>
        <
buildTimeoutSeconds>1200</buildTimeoutSeconds>
      </
nant>
    </
tasks>
    <
labeller type="iterationlabeller">
      <
prefix>1.0</prefix>
      <
duration>2</duration>
      <
releaseStartDate>2007/11/24</releaseStartDate>
      <
separator>.</separator>
    </
labeller>
  </
project>
</
cruisecontrol>

The End Result

Once you have everything setup you’ll need to

  1. Start up server\ccnet.exe to start CCNet in where you installed CCNet (or you can start the service).
  2. Install cctray\cctray.exe and add the BuildKnowledge Current project from your localhost.
  3. Force Build the project
  4. Run our BuildKnowledge.exe in the build folder

Build version

Thats all you have to do to add version numbers I hope you’ve gotten something out of this, we’ll be coverring more advanced topics next time.

Download the code: BuildKnowledge01.zip (4 KB)

Comments [1] | | # 
 Wednesday, November 14, 2007
Wednesday, November 14, 2007 5:00:18 PM (GMT Standard Time, UTC+00:00) ( )
So I finally moved over to actually blogging software but you might be wonderring where all the posts went to. Don't worry they're still around and I'm still posting in there.

Go checkout Sleepoverrated Stream via [Tumblr]

You can currently see it in the right hand nav but its not that obvious so I'll fix that in the upcoming site design.

Comments [0] | | # 
 Tuesday, November 13, 2007
Tuesday, November 13, 2007 9:56:27 PM (GMT Standard Time, UTC+00:00) ( )

Here’s a greasmonkey script I created to let you use google reader in full screen that has since been featured Greasemonkey script at LifeHacker.

In order to get access to the settings and search you can toggle back to the normal layout by pressing W.

If you have anything you’d like added please add a comment, I’ve heard it works well with Better GMail when displaying Google Reader on the same page.

Download at User Scripts

Install Greasemonkey

Keyboard shortcuts that come in handy are

w - toggle fullscreen (shows search bar again)

g t - go to tag
g u - go to subscription
g s - go to starred items

j - next item
k - prev item
s - star item

u - toggle left sidebar

Comments [4] | | #