如何在devenv任务中指定多个构建类型,CruiseControl.net

时间:2011-05-06 01:47:08

标签: c# visual-studio msbuild cruisecontrol.net devenv

我想做devenv的Clean and Build。我只是注意到buildtype标志只能有一个项目(Clean; Build not allowed)。你知道如何指定多个BuildTypes吗?

<tasks>
  <devenv>
    <solutionfile>C:\Source\Developer.sln</solutionfile>
    <configuration>Release</configuration>
    <buildtype>Build</buildtype> // How to do Clean and build here???
    <executable>C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.com</executable>
    <buildTimeoutSeconds>900</buildTimeoutSeconds>
  </devenv>
</tasks>

2 个答案:

答案 0 :(得分:2)

您需要完成两项任务。每个<devenv>块对应一个devenv.com调用。 devenv.com的选项只允许您/Clean/Rebuild而不是构建。如果你想先清理然后正常构建,你需要调用devenv.com两次,因此你需要两个任务。

答案 1 :(得分:1)

还有另外一种方法,即针对项目文件调用MSBUILD任务;这反过来调用devenv对解决方案文件;这样做的好处是可以更容易地集成思维,如单元测试,代码分析等。

以下是我的Common.Targets中的几个目标

<Target Name="Clean">
    <RemoveDir Directories="$(BuildFolder)" />
    <MakeDir Directories="$(BuildFolder)" Condition="!Exists('$(BuildFolder)')" />

    <MSBuild Projects="$(SolutionName).sln" Properties="ReferencePath=$(ReferencePath);Configuration=$(Configuration)" Targets="Clean" />
</Target>

<Target Name="Compile" DependsOnTargets="Version">
    <MSBuild Projects="$(SolutionName).sln" Properties="ReferencePath=$(ReferencePath);Configuration=$(Configuration);OutputPath=$(OutputPath);OutDir=$(OutputPath)\;DeployDir=$(CodeDeployFolder)\;Deploy=true;BuildConstants=$(BuildConstants)" />
</Target>

然后对于我有的CruiseControl任务

    <msbuild>
        <executable>C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable>
        <workingDirectory>code</workingDirectory>
        <projectFile>Mailer.proj</projectFile>
        <targets>BuildAll;DistributeLibrary</targets>
        <logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
    </msbuild>

这样还可以更轻松地在整个构建服务器场中添加新流程,例如:假设您想将StyleCop分析引入您的项目,您不必更改CC.NET设置只需引入/扩展CodeAnalysis目标并构建BuildAll的那部分