Cruise Control Tutorial
Embed Size (px)
Transcript of Cruise Control Tutorial
CruiseControl.Net Tutorial1. Introduction 2. Resources 3. Installation 3.1. Install CruiseControl.NET 3.2. Create a CCNet Website in IIS 3.3. Install Nunit 4. CruiseControl.NET Server Configuration General 5. Structure of a Project Configuration File 6. Source Control Block 7. Trigger Block 8. Labeller Block 9. Tasks Block 10. MsBuild Task 10.1. MSBuild and ReferencePath CruiseControl.NET not resolving reference to Nunit 10.2. An Alternative MSBuild Logger Christian Rodemeyers MsBuildToCCNet 10.3. CruiseControl.NET Webdashboard fails in finding images if not installed in virtual directory 10.4. MSBuildToCCNET reports wrong number of compiled projects 10.5. CruiseControl.NET, MsBuild Task and Resources Assembly Linker 10.6. CruiseControl.NET, MsBuild Task and Web Application projects 11. Nunit Task 11.1. Nunit Task 11.2. Executable Task 12. Publishers Block 13. PreBuild Block 13.1. Install Nant 13.2. Nant Fundamentals 1. Introduction In this article series I will review the various steps needed to setup and configure a working CruiseControl.Net server. The goal is to set up a Continuous Integration process for a sample project as close as possible to a real-life project. I will point out several issues that might arise and I will provide solutions as well. I will try to underline all the details that you need to be aware of. Thanks to Frank Geerlings for making me aware of a casing problem with the xml samples. By talking with WordPress support it came out that there was a little bug and they suggested me how to fix the problem.
2. Resources During the article I will guide you through the installation process of the following software: Subversion CruiseControl.NET Nunit Nant FxCop NantContrib The following are optional: TortoiseSVN AnkhSVN You can find information about how to install: Subversion, TortoiseSVN and AnkhSVN in the article: Guide to Versioning a Visual Studio Solution with Subversion, TortoiseSVN and AnkhSVN. There you can also find a quick guide about how to create a Subversion repository and how to add a Visual Studio solution to source control. This tutorial assumes that you have Subversion 1.4.6 installed and that you have configured a Subversion repository at the url: svn://localhost/trunk as shown in the article: Guide to Versioning a Visual Studio Solution with Subversion, TortoiseSVN and AnkhSVN. If you already have a working environment with a repository and versioned files, you can go on reading and replace the paths and names in the examples with the paths and names in your environment. 3. Installation
3.1. Install CruiseControl.NET 3.2. Create a CCNet Website in IIS 3.3. Install Nunit
This tutorial will assume that you install CruiseControl.NET on the same machine on which you had installed the Subversion repository. So, first of all, lets go through the steps needed to install CruiseControl.NET on your server machine.3.1. Install CruiseControl.NET
Download the latest CruiseControl.NET release from: SourceForge or the latest build from CCNetLive. You can find release notes here. For this article I used the installer for version 1.4 (CruiseControl.NET-1.4-Setup.exe), downloaded from the CCNetLive website. Run the setup executable file and, when prompted, you must specify your choices for a couple of actions: Install CC.Net server as windows service must be checked so that the setup will install CruiseControl as a Windows service. In the Services management console the CruiseControl service will be displayed with the name: CruiseControl.NET. Create virtual directory in IIS for Web dashboard will create a virtual directory named ccnet in the machines IIS web server. If you have an IIS server installation supporting multiple web sites (this is not the case for Windows XP Professional) and prefer to have a separate web site for the CCNet web dashboard you should uncheck this option. This is my choice. In the next paragraph I will show you how to create an IIS web site for the CruiseControl.NET web dashboard. When the install process is finished all the content will be installed in the folder: C:\%ProgramFiles%\CruiseControl.NET (e.g. C:\Program Files\CruiseControl.NET). Under this path you will find a directory called server, containing all the CCNet binary files and executables, and a directory called webdashboard, containing the CruiseControl.NET web interface.3.2. Create a CCNet Website in IIS
Here I will add and configure a Website in IIS for the CruiseControl.NET Webdashboard: the administrative interface of CruiseControl.NET. Open IIS Manager in Administrative Tools, right-click on the Web Sites node and select New Web Site. The Web site creation wizard will start. Click Next and you will be prompted for a Web Site Description. Type CCNet and click Next, leave Unassigned the IPAddress, choose a port number (say: 222) and leave empty the Host Header for this site field, then click Next. Choose C:\%ProgramFiles%\CruiseControl.NET\webdashboard as the path for the Website and click Next. Allow Read and Run scripts, the default, and click Next. The wizard is finished and the new Website created.3.3. Install Nunit
For the sake of our example we will need Nunit so, if you havent already done, install it on the same machine on which you have installed CruiseControl.NET. You can find the latest Nunit release here at SourceForge. This article is based on the release 2.4.6, currently the latest. You can install it by downloading: NUnit-2.4.6-net-2.0.msi.
After the installation you will have a new directory under %ProgramFiles% : C:\ %ProgramFiles%\NUnit 2.4.6. 4. CruiseControl.NET Server Configuration General All the configuration files were going to talk about are placed or are to be placed in: C:\%ProgramFiles%\CruiseControl.NET\server. CruiseControl.NET comes with two server executables: ccservice.exe which is the windows service installed by the installation setup and ccnet.exe which is a console application included for testing purposes. It is much easier to debug a console application that a service so I strongly suggest to make your initial tests with ccnet.exe and carefully read the console output to get familiar with CCNet behavior. Each of the two executables comes with a default configuration file (i.e.: ccservice.exe.config and ccnet.exe.config) that you dont need to change at the moment. Moreover both the server processes (windows service or console application) look for a file named ccnet.config in which you will place all the actual information needed by CCNet to learn what it is supposed to do and how it is supposed to do it. ccnet.config is an xml file with a root element named and a child element, named , for each set of activities that we want CruiseControl.NET to execute, as shown in the following example:1 2 3 ... 4 5 6 7 ...
In this tutorial we will setup our CruiseControl.NET configuration with two logical sets of activities. For the sake of clarity we will benefit of the usage of xml entities. Well define each project configuration in a separate file and import all the files in ccnet.config by means of entity definitions and entity declarations:1 < !DOCTYPE cruisecontrol [ 2 3 < !ENTITY project1 SYSTEM "file:project1.xml.config"> < !ENTITY project2 SYSTEM "file:project2.xml.config">
4 ]> 5 6 7 &project1; &project2;
Lets focus, at first, only on the first project, so delete the second entity reference (i.e.: &project2; ) thus obtaining:1 < !DOCTYPE cruisecontrol [ 2 3 4 ]> 5 6 &project1; 7 < !ENTITY project1 SYSTEM "file:project1.xml.config"> < !ENTITY project2 SYSTEM "file:project2.xml.config">
5. Structure of a Project Configuration File What we need to do now is creating a file named: project1.xml.config in C:\ %ProgramFiles%\CruiseControl.NET\server and use it to setup CruiseControl.NET main activities. This file will contain what is called the Project Configuration Block for the first CCNet activity that we want to configure. First of all we need to assign a unique name to the root of the Project Configuration Block: the tag. We then write:1 2 3 4 5 6 7 http://192.168.15.2:222 C:\develop\CCnet\project1WorkingDir C:\develop\CCnet\project1CCnetArtifacts ...
Lets talk about the first three children nodes: represents the URL at which the current project is available through the web interface. We will see later why it is useful.
For now just make sure to set it to the IP of the server machine (in which you installed CCNet) and to the port that you chose for the WebDashboard website when you configured the web site in IIS (see: 3.2. Create a CCNet Website in IIS). is the path to the main directory of this project and is meant to contain the checked out version of the project under integration. This path will be accessible as an environment variable: %CCNetWorkingDirectory%, available to external scripts (we will see it later). I use to place all the projects managed with CCNET in folders under a common directory named: C:\develop\CCnet. For this test project I chose: C:\develop\CCnet\project1WorkingDir. It is convenient to choose a directory in which to place all the stuff that will be used by CCNet (script files or executable files that you may want CruiseControl.NET to execute) as well as the workingDirectory in which CCNET will checkout the versioned files and the artifactDirectory in which it will output log files. In the example above I chose the directory: C:\develop\CCnet as the container of all CCNet related stuff. is the path to the directory where all the build logs for this project will be placed. Apart from the three tags described above, the main blocks that were going to add to the project configuration file are:
Source Control Block Trigger Block Labeller Block 9. Tasks Block 13. PreBuild Block 12. Publishers Block
6. Source Contr