Question

I'm setting up a continuous integration environment, using VisualSVN Server and CrusieControl.NET. What I want to do is delete the working copy before the MSBuild task starts?

I have read that I could use Nant or a Batch file which ccnet would invoke. What is best practice here? Any help on this would me great!

here is an extract of the section of ccnet.config

      <tasks>
        <msbuild>
            <ItemGroup>
                <FilesToDelete Include="C:\CruiseControl\Working\\\**\*"/>
            </ItemGroup>
            <Target Name="Task" DependsOn="Preparation">
                  build
            </Target>
            <Target Name="Preparation">
                  <Delete Files="@(FilesToDelete)" />
            </Target-->
            <executable>                                                      
                C:\WINDOWS\microsoft.net\Framework64\v3.5\MSBuild.exe                                              
            </executable> 
            <projectFile>Example.sln</projectFile>  
            <buildArgs>
                /p:Configuration=Release /p:MSBuildExtensionsPath=C:\Progra~2\MSBuild /p:MSBuildEmitSolution=1 /verbosity:minimal
            </buildArgs>                                                      
            <logger>
                C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll
            </logger>
        </msbuild>
      </tasks>
Was it helpful?

Solution

I have found the answer to my original question:

I simply had to put the cleanCopy true inside the sourcecontrol block.

<sourcecontrol type="svn">                                            
    <trunkUrl>TRUNK-URL</trunkUrl>                
    <executable>SVN.EXE</executable>           
    <username>TEST</username>                                         
    <password>TEST</password> 
    <cleanCopy>true</cleanCopy>         
  </sourcecontrol>

OTHER TIPS

I don't think modifying msbuild script is the easiest solution here. Deleting the working copy is not part of the build itself, it is part of the cc .net build process though. You need it when you build with cc.net, not when you build with VS or else.

What I would do is either do it with batch, powershell or a msbuild script. Deleting a directory is straightforward so I would recommend to do it with batch :

<prebuild>
     <exec>
        <executable>cmd.exe</executable>
        <buildArgs>/c "if exist "C:\CruiseControl\Working" rd /s /q "C:\CruiseControl\Working""</buildArgs>
    </exec>
</prebuild>

<tasks>

    <msbuild>
        <executable>                                                      
            C:\WINDOWS\microsoft.net\Framework64\v3.5\MSBuild.exe                                              
        </executable> 
        <projectFile>Example.sln</projectFile>  
        <buildArgs>
            /p:Configuration=Release /p:MSBuildExtensionsPath=C:\Progra~2\MSBuild /p:MSBuildEmitSolution=1 /verbosity:minimal
        </buildArgs>                                                      
        <logger>
            C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll
        </logger>
    </msbuild>
  </tasks>

you could actually make the first part of your MSBuild task prepare the release directory by doing the cleanup

you could do it by domain something similar to this

<ItemGroup>
    <FilesToDelete Include="<PathGoesHere>\**\*"/>
</ItemGroup>

<Target Name="Task" DependsOn="Preparation">
      //normal task happens here
</Target>

<Target Name="Preparation">
      <Delete Files="@(FilesToDelete)" />
</Target>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top