我想将ccnet.config
文件(或此项目的其他cc.net配置文件)存储在我项目的存储库(git)中,并在我从仪表板强制构建时使CC.NET使用它。我该怎么做?
谢谢!
答案 0 :(得分:3)
你的“ccnet.config”应该保持相当静态。
如果您的解决方案/项目构建需要不同的“逻辑”,那么我建议:
1. Write your ccnet.config code to pull source code from repository. (aka, Task #1)
2. In your repository, include a MasterBuild.proj (msbuild definition).
3. Have cc.net call msbuild.exe on MasterBuild.proj (aka, Task #2).
4. Have the majority of your logic inside the MasterBuild.proj file. That is what you check in/out of source control.
如果你认为CC.NET是一个“超级花哨的msbuild.exe执行者”,你的世界将会更有意义恕我直言。
这是一个非常基本的msbuild(定义)文件。 你可以称之为
MySolutionMasterBuild.proj(或类似)
将它放在与.sln文件相同的目录中(在源代码管理中)。
使用CC.NET下载代码。 然后连接msbuild.exe以调用以下文件。
然后在.proj文件中有任何额外的逻辑。
你可以做一些其他CC.NET的东西,比如发布邮件和合并任何结果xml,但大多数逻辑(我的偏好反正)..........将在文件如下。
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="AllTargetsWrapped">
<PropertyGroup>
<!-- Always declare some kind of "base directory" and then work off of that in the majority of cases -->
<WorkingCheckout>.</WorkingCheckout>
<ArtifactDestinationFolder>$(WorkingCheckout)\ZZZArtifacts</ArtifactDestinationFolder>
</PropertyGroup>
<Target Name="AllTargetsWrapped">
<CallTarget Targets="CleanArtifactFolder" />
<CallTarget Targets="BuildItUp" />
<CallTarget Targets="CopyFilesToArtifactFolder" />
</Target>
<Target Name="BuildItUp" >
<MSBuild Projects="$(WorkingCheckout)\MySolution.sln" Targets="Build" Properties="Configuration=$(Configuration)">
<Output TaskParameter="TargetOutputs" ItemName="TargetOutputsItemName"/>
</MSBuild>
<Message Text="BuildItUp completed" />
</Target>
<Target Name="CleanArtifactFolder">
<RemoveDir Directories="$(ArtifactDestinationFolder)" Condition="Exists($(ArtifactDestinationFolder))"/>
<MakeDir Directories="$(ArtifactDestinationFolder)" Condition="!Exists($(ArtifactDestinationFolder))"/>
<Message Text="Cleaning done" />
</Target>
<Target Name="CopyFilesToArtifactFolder">
<ItemGroup>
<MyExcludeFiles Include="$(WorkingCheckout)\**\*.doesnotexist" />
</ItemGroup>
<ItemGroup>
<MyIncludeFiles Include="$(WorkingCheckout)\bin\$(Configuration)\**\*.*" Exclude="@(MyExcludeFiles)"/>
</ItemGroup>
<Copy
SourceFiles="@(MyIncludeFiles)"
DestinationFiles="@(MyIncludeFiles->'$(ArtifactDestinationFolder)\%(Filename)%(Extension)')"
/>
</Target>
</Project>
答案 1 :(得分:0)
看一下场景 http://www.cruisecontrolnet.org/projects/ccnet/wiki/Build_Server_Scenarios
您可以在每个步骤中预见到构建脚本,您可以自己做。