Archive

Archive for July, 2006

Castle Monorail + Active Record + Testing + CreateSchemaFromFile

27 July, 2006 Comments off

It’s always a good idea to have your test database match your production database exactly, we can do that easily using:

ActiveRecordStarter.CreateSchemaFromFile()

Unlike CreateSchema which makes a best guess at how your schema should be CreateSchemaFromFile takes an SQL script which allows you to fully control the database schema.

Call CreateSchemaFromFile as part of your PrepareSchema method in your AbstractTestCase class.

protected virtual void PrepareSchema()
{
ActiveRecordStarter.DropSchema();
ActiveRecordStarter.CreateSchemaFromFile("schema.sql");
}

Your schema.sql file should contain scripts in the standard MS SQL format:

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Application_Status]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Application_Status]
GO

CREATE TABLE [dbo].[Application_Status] (
[ID] [int] NOT NULL ,
[Title] [varchar] (50) NOT NULL ,
[Description] [text] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

Categories: MonoRail

Continuous Integration + CruiseControl.Net + Subversion + MSBuild + .Net 2.0

20 July, 2006 10 comments

I’ve read quite a bit about Continuous Integration and the .Net implementation CruiseControl.Net. It always seemed like a really good idea but I’ve never gotten around to trying it out, until now…

By the way setting up the server was a lot easier than I thought it would be! Here’s what I did:

CruiseControl.Net Setup

Download and run CruiseControl.Net setup

http://sourceforge.net/project/showfiles.php?group_id=71179&package_id=83198

I’ve used version 1.0.1:

CruiseControl.NET-1.0.1-Setup.exe

NOTE: After setup if your server has .Net 1.1 and 2.0 as mine did you may need to change the ccnet website to use .Net 2.0. This can be done through the IIS control panel, get the properties of the ccnet site and change via the ASP.NET tab.

Subversion Client

Your server will need the subversion console client on the server to allow CruiseControl to checkout your source.

http://subversion.tigris.org/

.Net 2 SDK

To allow us to build .Net 2 projects without the need for Visual Studio we need to download and install .Net 2 SDK onto the server

http://www.microsoft.com/downloads/details.aspx?familyid=fe6f2099-b7b4-4f47-a244-c96d69c35dec&displaylang=en

Setup MSBuild

To use MSBuild with CC.Net we need the logger dll -ThoughtWorks.CruiseControl.MsBuild.dll from:

http://ccnetlive.thoughtworks.com/MSBuildXmlLogger%2DBuilds/

Download and copy to:
C:\Program Files\CruiseControl.NET\webdashboard\bin\

Directory structure

Setup your directory structure:

C:\CI\Myproject\
C:\CI\Myproject\build
C:\CI\Myproject\logs

Using your subversion client checkout source to C:\CI\MyProject\build

ccnet.config

Add the project config to ccnet.confg:

<cruisecontrol>
 <project name="MyProject">
  <!-- after a change is detected, wait 10 mins and then kick off the build-->
  <schedule type="schedule" sleepSeconds="600" />
  <!--set the sourcecontrol type to subversion and point to the subversion exe-->
  <sourcecontrol type="svn">
   <executable>C:\Program Files\Subversion\bin\svn.exe</executable>
   <workingDirectory>C:\CI\MyProject\build</workingDirectory>
   <trunkUrl>svn://svnserver/MyProject/trunk</trunkUrl>
   <autoGetSource>true</autoGetSource>
   <username>myuser</username>
   <password>mypassword</password>
  </sourcecontrol>
  <tasks>
   <!-- Configure MSBuild to compile the updated files -->c:\
   <msbuild>
    <executable>C:\windows\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe</executable>
    <workingDirectory>C:\CI\MyProject\build\src\</workingDirectory>
    <projectFile>MyProject.sln</projectFile>
    <buildArgs>/noconsolelogger /p:Configuration=Debug</buildArgs>
    <targets></targets>
    <timeout>15</timeout>
    <logger>ThoughtWorks.CruiseControl.MsBuild.XmlLogger,C:\Program Files\CruiseControl.NET\webdashboard\bin\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
   </msbuild>
  </tasks>
  <!--Publishers will be done after the build has completed-->
  <publishers>
   <xmllogger>
    <logDir>C:\CI\MyProject\Logs</logDir>
   </xmllogger>
  </publishers>
  <modificationDelaySeconds>10</modificationDelaySeconds>
 </project>
</cruisecontrol>

CC Tray

You will also want to install the CC Tray monitoring software on your pc:

CCTray

It will allow you to keep an eye on the server from the comfort of your own pc.

That’s it we’re down!

Categories: General