To keep your code clean and in a compiled form we need to keep track that no erroneous file gets checked-in to your code repository. The best way to perform this is to use an autobulid process when a new checkin in repository happens. Recently I tried to perform the same and so came to write about the quick steps
First of all, you need tools that will automatically keep your code clean and without an erroneous file by performing an autobulid process when a new checkin to the repository is done. I recommend the CruiseControl .Net tool for this. It's free and open source.
If you're using an SVN subversion control then it requires an svn client to get the latest source code and checkin detection.
I prefer
Collabnet subversion client.
Download Cruise Control and Install it with easy next –> next –> finish steps. It'll ask you to create an IIS website so make sure you've IIS installed. The website will be your dashboard to check your build status and reports.
Once you are done with the installation, go to the directory where you installed the tool. The default path for this is:
For (64 bit)
C:\Program Files (x86)\CruiseControl.NET
For (x86)
C:\Program Files\CruiseControl.NET
Now go to the "server" subdirectory on the above location and you'll find the ccnet.config file. Open this file in your favourite XML editor (mine is NotePad++). In case you're using Notepad++ don't forget to select the language from the menu to choose XML.
Edit your ccnet.config file with your project, svn and other details like in the following sample:
- <cruisecontrol xmlns:cb="urn:ccnet.config.builder">
- <project name="Code library - 1.0 - Local">
-
- <workingDirectory>D:\Projects\CodeLibrary\</workingDirectory>
-
- <artifactDirectory>D:\Artifacts</artifactDirectory>
-
- <webURL>http://localhost/ccnet</webURL>
-
- <triggers>
-
- <intervalTrigger name="continuous" seconds="300" buildCondition="IfModificationExists" />
- </triggers>
-
- <labeller type="defaultlabeller">
- <prefix>1.0.</prefix>
- <incrementOnFailure>false</incrementOnFailure>
- <labelFormat>0000</labelFormat>
- </labeller>
-
- <sourcecontrol type="svn">
- <trunkUrl>http://amit.subverions.url/svn/CodeLibrary</trunkUrl>
- <workingDirectory>D:\Projects\CodeLibrary\</workingDirectory>
- <executable>C:\Program Files (x86)\CollabNet\Subversion Server\svn.exe</executable>
- <username>svn_user</username>
- <password>svn_pwd</password>
- <autoGetSource>true</autoGetSource>
- <tagOnSuccess>false</tagOnSuccess>
- <tagBaseUrl></tagBaseUrl>
- </sourcecontrol>
-
- <tasks>
- <msbuild>
- <executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
- <workingDirectory>D:\Projects\CodeLibrary\</workingDirectory>
- <projectFile>Amit.Tests.Tools.CodeLibrary.sln</projectFile>
- <buildArgs>/noconsolelogger /p:Configuration=Release /p:Platform="Any CPU" /v:diag </buildArgs>
- <targets>Build</targets>
- <timeout>600</timeout>
-
- <logger>C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
- </msbuild>
- </tasks>
-
- <publishers>
- <merge>
- <files>
- <file>K:\Artifacts\msbuild-results.xml</file>
- </files>
- </merge>
- <xmllogger />
- <statistics/>
- </publishers>
- </project>
- </cruisecontrol>
When you are done editing save it and close it.
Now open the file.
C:\Program Files (x86)\CruiseControl.NET\webdashboard\dashboard.config
- <buildReportBuildPlugin>
- <xslFileNames>
- <xslFile>xsl\header.xsl</xslFile>
- <xslFile>xsl\modifications.xsl</xslFile>
- <xslFile>xsl\compile.xsl</xslFile>
- <xslFile>xsl\compile-msbuild.xsl</xslFile>
- </xslFileNames>
- </buildReportBuildPlugin>
- <buildLogBuildPlugin />
Add the above mentioned XSL files. These templates are already installed with your CruiseControl tool.
Now you're almost done with configuration.
Go to services and start CruiseControlServer
Once the service started it'll start watching your project for the latest checkins. If the service is not starting then there's a problem with your configuration XML. Double-check it.
Now open the url http://localhost/ccnet make sure it's showing you cruise control dashboard and your project name is visible there.
And you're done. Now download the CCTray from the above dashboard and add a project as HTTP url(i.e.http://localhost/ccnet) from the add server setting. If it's connected it'll show you the project and its state with color-coding 'Green' (Means everything is ok).
Now checkin a code file in your project and watch it building from CCTray.
Troubleshooting
-
Web dashboard is not showing my project
Make sure you've placed your ccnet.config in the server directory and it's updated with your project info. and that the Cruise control services are running.
-
error – Your svn copy is too old to work with the subversion svn client.
Try to download an earlier version of collabnet subversion svn client and restart the service again. Further if it can give an error – Your svn subversion is too old to work with your svn repository. Now you can install your previous collabnet subversion client and it should work.
-
MSbuild task failed -
Make sure your arguments and project directory information are correctly specified in the ccnet.config file. Try to run the MSBuild command argument in vs command prompt if it works fine there then it will definitely work here.