4

I am working setting up my continuous integration server using Teamcity and I have three steps for my build (.NET/VS2010/MSBUILD)

  1. Use MSBUILD to build my solution.
  2. Run NUnit Tests.
  3. Use MSBUILD to do a Web deploy of my projects.

The issue I am trying to solve is to prevent step 3 from running if any of the test fail. Is this possible?

sll
  • 61,540
  • 22
  • 104
  • 156
Derek Smith
  • 231
  • 1
  • 8
  • If your tests fail, does your build fail? If not, that's where I'd concentrate. Once you have that working you could opt to push the web deploy into a separate build that is dependent on your actual build. I prefer that option as I think they're independent processes, and should succeed/fail separately. – Merlyn Morgan-Graham Nov 18 '11 at 13:47
  • Unfortunately it does not appear that this is possible at this time using teamcity http://youtrack.jetbrains.net/issue/TW-12194 – iamkrillin Nov 18 '11 at 04:51

1 Answers1

2

You can do this using NUnit MsBuild Community task by handling Output parameter "ExitCode" and then executing MSBuild Error Task depends on "ExitCode" or execute Deploy task/targets depends on this condition, so it is up to you.

Error task:

Stops a build and logs an error based on an evaluated conditional statement. The Error task allows MSBuild projects issue error text to loggers and stop build execution

<!-- Build -->
<Build .... />

<!-- Run tests -->
<Nunit ....>
   <Output TaskParameter="ExitCode" 
           PropertyName="NUnitResult" />

<!-- Stop build in case of error whilst tests run -->    
<Error Text="Tests failed"
       Code="$(NUnitResult)"
       Condition="'$(NUnitResult)' != '0'"/>

<!-- Deploy -->    
<Deploy Condition="'$(NUnitResult)' != '0'"/ ... />
sll
  • 61,540
  • 22
  • 104
  • 156
  • Right now I am using multiple build steps in TeamCity. So while the build could fail, all steps in the process would be executed. I was hoping to do it all in the MSBuild file, however I could not find documentation on a build task that would run the Web Deploy publishing. I was going to possibly try running MSDeploy.exe using the Exec task. – Derek Smith Nov 22 '11 at 02:00