Msbuild 保持持续集成的更好方法?

Msbuild 保持持续集成的更好方法?,msbuild,continuous-integration,cruisecontrol.net,Msbuild,Continuous Integration,Cruisecontrol.net,我发现在添加新项目时,我总是在调整CI设置。毫无疑问,对于很少更改的现有代码来说,这些好处是非常棒的,但新项目或批量项目似乎需要更多的工作,因为我必须将每个项目配置为“集成”,并维护一个不断增长的CCNET.config文件。除了构建实用程序来管理添加和修改CI设置之外,还有更好的策略吗?我做了一些事情来控制它: 1) 将配置文件一分为二。我有一个文件基本保持不变,包含一组常量,例如 <?xml version="1.0" encoding="utf-8"?> <cruisec

我发现在添加新项目时,我总是在调整CI设置。毫无疑问,对于很少更改的现有代码来说,这些好处是非常棒的,但新项目或批量项目似乎需要更多的工作,因为我必须将每个项目配置为“集成”,并维护一个不断增长的CCNET.config文件。除了构建实用程序来管理添加和修改CI设置之外,还有更好的策略吗?

我做了一些事情来控制它:

1) 将配置文件一分为二。我有一个文件基本保持不变,包含一组常量,例如

<?xml version="1.0" encoding="utf-8"?>
<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
  <!-- Constant definition used by the projecct config to prevent changes being required for each iteration -->
  <cb:define branch="branch name for source control"/>
  <cb:define ciserver="Server name in here"/>
  <cb:define devenv="Path to DEVENV"/>
  <cb:define nunit="Path to NUNIT"/>
  <cb:define cruisecontrol="Cruisecontrol Path"/>

  <!-- Include file to the standard CI project definitions. This file is kept under source control -->
  <cb:include href="config\CCProjects.config"/>
</cruisecontrol>

常数的使用允许您进行单个更改,并使其在配置文件中的每个任务中传播

2) 将项目所在的文件置于源代码管理下。项目文件将作为SVN签出的一部分进行更新。这有助于跟踪所做的更改,并让您无需太多麻烦即可回滚


也许CC.Net已经到了对你不利而不是对你有利的地步。我听说过其他CI服务器易于配置的优点,例如,但它可能不适合您的构建环境。

1/根据需要拆分配置文件

例如,我有一个常量部分,每个项目都是一个include,因此我可以非常独立地更新每个项目,并跨项目使用常量

ccnet.config

<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
  <!-- Shared constants -->
  <cb:define WorkingFolderBase="D:\dev\ContinuousIntegration\WC" />
  <cb:define ArtifactFolderBase="D:\dev\ContinuousIntegration\Artifact" />
  <cb:define ConfigFolder="projects" />
  <cb:define SvnBasePath="http://myserver.com/svn" />
  <cb:define SvnUsername="Myusername" />
  <cb:define SvnPassword="MyPassword" />

  <!-- MyProject1  -->
  <cb:include href="projects/MyProject1.config"/>

  <!-- MyProject2  -->
  <cb:include href="projects/MyProject2.config"/>
</cruisecontrol>
<project name="MyProject1" queue="Q1" queuePriority="1">
  <artifactDirectory>$(ArtifactFolderBase)\MyProject1</artifactDirectory>
  <workingDirectory>$(WorkingFolderBase)\MyProject1</workingDirectory>
  <!-- SVN implementation -->
  <sourcecontrol type="svn" username="$(SvnUsername)" password="$(SvnPassword)">
    <trunkUrl>$(SvnBasePath)/MyProject1/trunk/</trunkUrl>
    <workingDirectory>$(WorkingFolderBase)\MyProject1</workingDirectory>
  </sourcecontrol>
  [...]
</project>

MyProject1.config

<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
  <!-- Shared constants -->
  <cb:define WorkingFolderBase="D:\dev\ContinuousIntegration\WC" />
  <cb:define ArtifactFolderBase="D:\dev\ContinuousIntegration\Artifact" />
  <cb:define ConfigFolder="projects" />
  <cb:define SvnBasePath="http://myserver.com/svn" />
  <cb:define SvnUsername="Myusername" />
  <cb:define SvnPassword="MyPassword" />

  <!-- MyProject1  -->
  <cb:include href="projects/MyProject1.config"/>

  <!-- MyProject2  -->
  <cb:include href="projects/MyProject2.config"/>
</cruisecontrol>
<project name="MyProject1" queue="Q1" queuePriority="1">
  <artifactDirectory>$(ArtifactFolderBase)\MyProject1</artifactDirectory>
  <workingDirectory>$(WorkingFolderBase)\MyProject1</workingDirectory>
  <!-- SVN implementation -->
  <sourcecontrol type="svn" username="$(SvnUsername)" password="$(SvnPassword)">
    <trunkUrl>$(SvnBasePath)/MyProject1/trunk/</trunkUrl>
    <workingDirectory>$(WorkingFolderBase)\MyProject1</workingDirectory>
  </sourcecontrol>
  [...]
</project>

$(ArtifactFolderBase)\MyProject1
$(WorkingFolderBase)\MyProject1
$(SvnBasePath)/MyProject1/trunk/
$(WorkingFolderBase)\MyProject1
[...]
2/在CC.NET(我建议在整个安装过程中)或配置文件上使用版本控制

3/保持简单通过批处理文件执行所有操作(编译应用程序、编译测试、运行测试、获取覆盖率、静态分析器、生成报告…)