华赐软件 Bootstrap3

CC.Net配置(原创)

一、CC.NET整体流程图

二、软件准备:

1.CC.NET核心

这里我用的版本是:CruiseControl.NET-1.8.0.0-Setup.exe,下载地址:http://sourceforge.net/projects/ccnet/files/CruiseControl.NET%20Releases

还有两个辅助工具:

a.CruiseControl.NET-CCTray-1.8.0.0-Setup.exe,在远程机器可以执行CC.NET运行b.CruiseControl.NET-Tools-1.8.0.0-Setup.exe 辅助CC.NET的配置

2.各种集成到CC.NET的工具

a.MSTest 单元测试这个VS自带的,不用独立安装

b.Nunit 也是单元测试工具,MSTest和Nunit各有优劣,选其一种即可

c.FxCop 静态代码检查工具,这里我用的版本是FxCop10.0Setup.rar,VS里面也有集成,用它集成到CC.NET,可以和VS的方便作比较修改

d.NCover     单元测试覆盖率统计工具,目前是收费的,目前没有发现集成到CC.NET合适的版本,这里我用的版本是NCover3.1.2.5168.rar,通过TestDriven.NET-3.0.2749_Personal联合VS一起手工执行统计的,这里会生成的报告可以继承到CC.NET中去

e.圈复杂度统计工具,这里我用的是SourceMonitor,这个工具是免费的,统计功能很强大,但是用它统计出来的结果与它集成到VS统计出来的结果有点出入,个别喝文件比VS统计出来的偏大点

 

三、CC.NET配置  ccnet.config

ccnet.config是CC.NET的核心,即使插件安装成功了,如果配置有问题,CC.NET是运行不起来了,统计功能也是无从谈起了。

下面一步一步讲解如何配置

1.去CC.NET安装目录,找到ccnet.config这个文件:如C:\Program Files\CruiseControl.NET\server\ccnet.config

刚打开,它只有这么一行:这是XML格式的

<cruisecontrol xmlns:cb="urn:ccnet.config.builder"/>

接下来,我们创建一个项目:

<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
  <!-- This is your CruiseControl.NET Server Configuration file. Add your projects below! -->
  <project name="ProjectName" webURL="http://ip:8000/server/local/project/Megalab/ViewProjectReport.aspx">
</
project>
</
cruisecontrol >

注释:name是指项目名称,webURL是指通过这个URL可以查看这个项目的所有集成信息,cc.net是asp.net 2.0的开发的网站系统,其实你IIS配置http://ip:端口或http://域名也可以访问

2.配置工作目录

<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
  <!-- This is your CruiseControl.NET Server Configuration file. Add your projects below! -->
  <project name="ProjectName" webURL="http://ip:8000/server/local/project/ProjectName/ViewProjectReport.aspx">
<!--工作目录,下载的源码将会被保存在这个目录下,如没有设置则会自被保存在安装目录下server子目录以project name为名称的目录下-->
    <workingDirectory>D:\DailyBuild\ProjectName\</workingDirectory>

    <!--这个目录保存每次编译的结果,对这个项目的监控过程的日志记录目录-->
    <artifactDirectory>D:\DailyBuild\ProjectName\log</artifactDirectory>
</project>
</cruisecontrol >

注释都在代码里面

 

3.配置定时任务的触发器

<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
  <!-- This is your CruiseControl.NET Server Configuration file. Add your projects below! -->
  <project name="ProjectName" webURL="http://ip:8000/server/local/project/ProjectName/ViewProjectReport.aspx">
<!--工作目录,下载的源码将会被保存在这个目录下,如没有设置则会自被保存在安装目录下server子目录以project name为名称的目录下-->
    <workingDirectory>D:\DailyBuild\ProjectName\</workingDirectory>

    <!--这个目录保存每次编译的结果,对这个项目的监控过程的日志记录目录-->
    <artifactDirectory>D:\DailyBuild\ProjectName\log</artifactDirectory>

    <triggers>
      <scheduleTrigger time="23:00:00" buildCondition="ForceBuild" name="Scheduled">
        <!--我现在用时间触发器,每天00:00编译程序-->
        <weekDays>
          <!--星期天休息,不编译-->
          <!--<weekDay>Sunday</weekDay>-->
          <!--<weekDay>Monday</weekDay>
          <weekDay>Tuesday</weekDay>
          <weekDay>Wednesday</weekDay>-->
          <weekDay>Thursday</weekDay>
          <!--<weekDay>Friday</weekDay>
          <weekDay>Saturday</weekDay>-->
        </weekDays>
      </scheduleTrigger>
    </triggers>
</project>
</cruisecontrol >

4.配置SVN

<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
  <!-- This is your CruiseControl.NET Server Configuration file. Add your projects below! -->
  <project name="ProjectName" webURL="http://ip:8000/server/local/project/ProjectName/ViewProjectReport.aspx">
<!--工作目录,下载的源码将会被保存在这个目录下,如没有设置则会自被保存在安装目录下server子目录以project name为名称的目录下-->
    <workingDirectory>D:\DailyBuild\ProjectName\</workingDirectory>

    <!--这个目录保存每次编译的结果,对这个项目的监控过程的日志记录目录-->
    <artifactDirectory>D:\DailyBuild\ProjectName\log</artifactDirectory>

    <triggers>
      <scheduleTrigger time="23:00:00" buildCondition="ForceBuild" name="Scheduled">
        <!--我现在用时间触发器,每天00:00编译程序-->
        <weekDays>
          <!--星期天休息,不编译-->
          <!--<weekDay>Sunday</weekDay>-->
          <!--<weekDay>Monday</weekDay>
          <weekDay>Tuesday</weekDay>
          <weekDay>Wednesday</weekDay>-->
          <weekDay>Thursday</weekDay>
          <!--<weekDay>Friday</weekDay>
          <weekDay>Saturday</weekDay>-->
        </weekDays>
      </scheduleTrigger>
    </triggers>
<sourcecontrol type="svn">
      <!--Pass-->
      <!--//服务器上项目文件的地址-->
      <trunkUrl>https://ip/svn/ProjectName/trunk/00 Code/ProjectName.Solution</trunkUrl>
      <!--//svn程序路径-->
      <executable>C:\Program Files\Subversion\bin\svn.exe</executable>
      <!-- //下载在本地磁盘路径,名字自定义-->
      <workingDirectory>D:\DailyBuild\ProjectName\src</workingDirectory>
      <!--能访问svn的用户名和密码-->
      <username>user</username>
      <password>pwd</password>
    </sourcecontrol>
</project> </cruisecontrol >

5.配置自动构造MSBuild

<tasks>
      <!--自动构建工具配置-->
      <!--Pass-->
       <msbuild>
       <!--msbuild的路径,一般在系统目录下-->
        <executable>C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable>
          <!--下载到本机的项目代码路径-->
        <workingDirectory>D:\DailyBuild\ProjectName\src</workingDirectory>
        <!--解决方案文件,相对project 的workingDirectory,MSBuild会找到这个文件,并对它进行编译-->
        <projectFile>Project.sln</projectFile>
        <!--编译参数-->
        <buildArgs>/p:Configuration=Debug /v:diag</buildArgs>
        <!--<buildArgs>/t:Build /p:Configuration=Release</buildArgs>-->
        <!--编译的目录类型-->
        <targets>Build</targets>
        <!--过期时间-->
        <timeout>900</timeout>
        <!--记录编译的详细日志,需要单独下载这个程序集,放在工作目录(workingDirectory)下 -->
        <logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
      </msbuild>

6.配置单元测试MSTest

<!--单元测试配置-->
      <!--MSTest-->
      <!--Delete alreadly exsisted mstest-results.xml file-->
      <!--<exec>
        <executable>D:\DailyBuild\ProjectName\bat\DelOldMSTestLog.bat</executable>
      </exec>
      <exec>
        <executable>D:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe</executable>
        <baseDirectory>D:\DailyBuild\ProjectName\src\</baseDirectory>
        <buildArgs>/testcontainer:"D:\DailyBuild\ProjectName\src\ProjectName.Business.Test\bin\Debug\ProjectName.Business.Test.dll" /testcontainer:"D:\DailyBuild\ProjectName\src\ProjectName.DataAccess.Test\bin\Debug\ProjectName.DataAccess.Test.dll" /resultsfile:"D:\DailyBuild\ProjectName\log\MSTestLogs\mstest-results.xml"</buildArgs>
      </exec>-->

7.配置静态代码检查Foxcop

<!--FxCop-->
        <exec>
          <executable>D:\Program Files\Microsoft Fxcop 10.0\FxCopCmd.exe</executable>
          <baseDirectory>D:\DailyBuild\ProjectName\</baseDirectory>
          <buildArgs> /p:log\FxCop\DailyBuild.FxCop /o:"D:\DailyBuild\ProjectName\log\FxCop\FxCop-results.xml"</buildArgs>
          <buildTimeoutSeconds>120</buildTimeoutSeconds>
        </exec>

 8.配置邮件

<!--Email-->
      <email mailport="587" includeDetails="TRUE" mailhostUsername="test@163.com" mailhostPassword="test" useSSL="true">
        <from>test@163.com</from>
        <mailhost>smtp.163.com</mailhost>
        <users>
          <user name="user1" group="PM" address="user1@163.com" />
<user name="QA" group="QA" address="qa@163.com"/> <user name="user2" group="DevLeader" address="user2@163.com" /> <user name="user3" group="Developers" address="user3@163.com" /> <user name="user4" group="Developers" address="user4@163.com" /> <user name="user5" group="TestLeader" address="user5@163.com" /> <user name="user6" group="Testers" address="user6@163.com" />
</users> <groups> <group name="PM"> <notifications> <notificationType>Always</notificationType> </notifications> </group> <group name="DevLeader"> <notifications> <notificationType>Always</notificationType> </notifications> </group>
<group name="Developers"> <notifications> <notificationType>Failed</notificationType> <notificationType>Fixed</notificationType> </notifications> </group> <group name="QA"> <notifications> <notificationType>Always</notificationType> </notifications> </group>
         <group name="TestLeader">
            <notifications>
              <notificationType>Success</notificationType>
            </notifications>
          </group>

<group name="Testers"> <notifications> <notificationType>Success</notificationType> </notifications> </group> <group name="buildmaster"> <notifications> <notificationType>Always</notificationType> </notifications> </group> </groups> <!--<converters> <regexConverter find="{1}quot;" replace="@163.com" /> </converters>--> <modifierNotificationTypes> <NotificationType>Failed</NotificationType> <NotificationType>Fixed</NotificationType> <notificationType>Always</notificationType> </modifierNotificationTypes> <subjectSettings> <subject buildResult="StillBroken" value="Build is still broken for Megalab Project"/> </subjectSettings> <xslFiles> <file>xsl\header.xsl</file> <file>xsl\compile.xsl</file> <file>xsl\unittests.xsl</file> <file>xsl\modifications.xsl</file> </xslFiles> <attachments> <file> <!-- path to file --> </file> </attachments> </email>

9.集成报告文件到CC.NET

<merge>
        <files>
          <!--NUnit Result-->
          <!--<file>D:\DailyBuild\ProjectName\log\NUnitLogs\nunit-results.xml</file>-->
          <!--MSTest Result-->
          <file>D:\DailyBuild\ProjectName\log\MSTestLogs\mstest-results.xml</file>
          <!--FxCop Result-->
          <file>D:\DailyBuild\ProjectName\log\FxCop\FxCop-results.xml</file>
          <!--<file>D:\DailyBuild\ProjectName\log\NCoverLogs\Coverage.xml</file>
          <file>D:\DailyBuild\ProjectName\log\NCoverLogs\CoverageReport.xml</file>-->
        </files>
      </merge>

10.完整CC.NET配置  点击下载

本文除图片外,所有文字描述为作者原创,转载请注明出处,谢谢!

posted @ 2013-05-28 10:55  OpenCsharp.Net  阅读(403)  评论(0编辑  收藏  举报
华赐软件 Bootstrap3
w.huacisoft.com">华赐软件 Bootstrap3