突然發現有人已經寫了一篇非常詳細的 CruiseControl.NET 的安裝指南,我想我也不可能寫的比他還詳細。有興趣的人可以先看這一篇,再跟我的設定對照參考。
我的機器上安裝了下列相關軟體:
- .NET Framework v1.1
- Visual Studio .NET 2003
- Perforce 2004.2
- CruiseControl.NET 0.7
- NAnt 0.85
- NAntContrib 0.85
- NUnit 2.2
- NDoc 1.3
- FxCop 1.312
CruiseControl.NET 設定的重點就是 server\ccnet.config:
<cruisecontrol>
<project name="PViewer">
<webURL>http://baby.homeip.net/ccnet/</webURL>
<workingDirectory>d:/temp/ccnet/</workingDirectory>
<triggers>
<pollingInterval seconds="60" />
<forceBuildSchedule time="05:00" />
</triggers>
<labeller type="defaultlabeller">
<prefix>ccnet-pviewer-</prefix>
</labeller>
<modificationDelaySeconds>10</modificationDelaySeconds>
<sourcecontrol type="p4">
<view>//depot/src/main/...</view>
<executable>C:\Program Files\Perforce\p4.exe</executable>
<client>CCNET</client>
<user>Patrick</user>
<port>10.10.1.6:1666</port>
<autoGetSource>true</autoGetSource>
</sourcecontrol>
<build type="nant">
<executable>NAnt.exe</executable>
<buildFile>src\main\PViewer\PViewer.build</buildFile>
<targetList>
<target>all</target>
</targetList>
</build>
<publishers>
<xmllogger />
</publishers>
<tasks>
<merge>
<files>
<file>src\main\PViewer\Test\bin\release\*.xml</file>
<file>src\main\PViewer\bin\release\*.xml</file>
</files>
</merge>
</tasks>
</project>
</cruisecontrol>
主要的設定分成三個範圍:
- line 18-25: 相關 Perforce 的設定以便定時查詢及更新原始碼
- line 27-33: 呼叫 NAnt 編譯、測試、產生說明文件、打包安裝檔
- line 35-46: 設定 log 檔的格式及其包含的內容,對照我的 NAnt script 可以看出其中包含了 NUnit 及 FxCop 的測試結果。
PViewer.build:
<project name="PViewer" default="all">
<property name="configuration" value="release"/>
<target name="build">
<solution configuration="${configuration}" solutionfile="PViewer.sln" />
<property name="expected.output" value="bin/${configuration}/PViewer.exe"/>
<fail unless="${file::exists(expected.output)}">Output file doesn't exist in ${expected.output}</fail>
</target>
<target name="docs" depends="build">
<ndoc>
<assemblies basedir="bin/${configuration}">
<include name="PViewer.Imaging.dll" />
</assemblies>
<documenters>
<documenter name="MSDN">
<property name="OutputDirectory" value="doc\MSDN" />
<property name="HtmlHelpName" value="PViewer" />
<property name="HtmlHelpCompilerFilename" value="hhc.exe" />
<property name="IncludeFavorites" value="False" />
<property name="Title" value="PViewer Class Library" />
<property name="SplitTOCs" value="false" />
<property name="DefaulTOC" value="" />
<property name="ShowVisualBasic" value="true" />
<property name="ShowMissingSummaries" value="true" />
<property name="ShowMissingRemarks" value="true" />
<property name="ShowMissingParams" value="true" />
<property name="ShowMissingReturns" value="true" />
<property name="ShowMissingValues" value="true" />
<property name="DocumentInternals" value="false" />
<property name="DocumentProtected" value="true" />
<property name="DocumentPrivates" value="false" />
<property name="DocumentEmptyNamespaces" value="false" />
<property name="IncludeAssemblyVersion" value="false" />
<property name="CopyrightText" value="" />
<property name="CopyrightHref" value="" />
</documenter>
</documenters>
</ndoc>
</target>
<target name="test" depends="build">
<nunit2>
<formatter type="Xml" usefile="true" extension=".xml" />
<test assemblyname="Test/bin/${configuration}/PViewer.Test.dll" />
</nunit2>
</target>
<target name="fxcop" depends="build">
<exec program="c:\tools\Microsoft FxCop 1.312\fxcopcmd">
<arg value="/out:bin/${configuration}/pviewer.fxcop.xml" />
<arg value="/file:bin/${configuration}/pviewer.imaging.dll" />
<arg value="/file:bin/${configuration}/pviewer.exe" />
</exec>
</target>
<target name="dist" depends="build">
<exec program="devenv" commandline="PViewer.sln /build release /project Setup" verbose="true" />
</target>
<target name="all" depends="build, docs, test, fxcop, dist" />
<target name="clean" description="Delete all previously compiled binaries.">
<delete>
<fileset>
<include name="**/bin/**" />
<include name="**/obj/**" />
<include name="**/*.suo" />
<include name="**/*.user" />
</fileset>
</delete>
</target>
<target name="rebuild" depends="clean, build" />
</project>