views:

810

answers:

4

I want to build a developer build project and then needs to publish it to the server and After a successful publish need to build my test project against that developer publish. Basic idea is to run this process whenever any developer commits something on Svn.

Currently I am using CC.net and MSBuild. Any one ahaving idea how to accomplish this work.

Step 1. Developer commit on SVN Step 2. Detect Changes on Svn and take an update on Build server Step 3. Build the project with recent changes Step 4. Publish it to the server Step 5. then run tests against the recent publish (I am successfully doing this process by using cc.net, msbuild and nunit)

A: 

if you're using the Project tag, you can also include "in it" the publisher for it. For example:

<project >  
 <tasks>  ... 
 </tasks>   
<publishers> 
 <buildpublisher>   
   <sourceDir>path with built binaries</sourceDir>
   <publishDir>path that will be shared</publishDir>
  </buildpublisher> 
 </publishers> 
</project>
I have tried using this method, but it is not publishing, rather it is copying all the files in source dir to destination dir. What I want is to publish webite on a server. Any idea how to do this
sam
+1  A: 

The publisher section in CC.Net will be executed regardless if the build is successful or fails. You need to add the 'publish to build server' as a task, under the tasks section - putting it after your last build step.

This will cause CC.Net to only 'publish to build server' when all previous 'tasks' are completed, without raising an error code.

Typically, if you know what is needed in a DOS .bat file to 'publish to build server' you do as follows;

<tasks>
    <msbuild>
        <executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
        <workingDirectory>c:\Somewhere</workingDirectory>
        <projectFile>Something.sln</projectFile>
        <buildArgs>/noconsolelogger /p:Configuration=Debug /v:m</buildArgs>
        <targets>Build</targets>
        <timeout>720</timeout>
        <logger>C:\program files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
    </msbuild>
    <exec>
        <executable>C:\program files (x86)\CruiseControl.NET\server\PublishToServer.bat</executable>
        <baseDirectory>C:\somewhere</baseDirectory>
        <buildArgs></buildArgs>
        <buildTimeoutSeconds>9000</buildTimeoutSeconds>
    </exec>
</tasks>

As slawekg points out, you can use the buildpublisher, which will execute only if the build is successful, however I still find using a batch file to do the copying more configurable than what is available using buildpublisher.

Thies
How to write a Dos .bat file for publishing. Can you plz send me the code
sam
A: 

because I cannot comment yet (50 points required) I'll answer again. You see, Thies, you're wrong. Take a look at: http://confluence.public.thoughtworks.org/display/CCNET/Build+Publisher

"...The Build Publisher lets you copy any arbitrary files on a successful build. You can set alwaysPublish to true, if you want the copy always to happen...."

So my answer is good enought.

chill dude!!!!!
kenny
sorry, I really didn't wanted to sound rude or something ;/I won't edit this answer, let it stay in original form.
A: 

You might also consider writing the "push" into your MS Build Script. This would give you the flexibility and control that Sam is talking about and still ensure that the publish only happens if the build succeeds.

RepDetec