【问题标题】:How to specify multiple buildtypes in devenv tasks, CruiseControl.net如何在 devenv 任务中指定多个构建类型,CruiseControl.net
【发布时间】:2011-05-06 01:47:07
【问题描述】:

我想在 devenv 中进行清理和构建。我刚刚注意到 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>

【问题讨论】:

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


    【解决方案1】:

    你需要两个任务。每个&lt;devenv&gt; 块对应一个devenv.com 调用。 devenv.com 的选项仅允许您使用 /Clean/Rebuild 而不是构建。如果您想先清理然后正常构建,则需要调用 devenv.com 两次,因此您需要两个任务。

    【讨论】:

      【解决方案2】:

      还有另一种解决方法,即针对项目文件调用 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 的一部分

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-03-03
        • 2013-02-06
        • 1970-01-01
        • 2010-09-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多