As you may have read in an earlier post, I’m currently helping a customer migrate their project from Visual Studio .NET 2003 to Visual Studio 2005. Our current build script uses NAnt, and we’re in the process of converting it to MSBuild. Since we’re big fans of continuous integration, and we depend on our Ambient Orb for at-a-glance build status, we have a need to replicate the behavior of NAnt’s OnSuccess and OnFailure properties.
I wasn’t able to find similar MSBuild functionality by browsing through the limited information I have (or can find on the internet), so I sent an e-mail to our internal team, and Alex Kipman was kind enough to suggest this solution:
<Project DefaultTargets=“A;OnSuccess“ >
<Target Name=“A“ DependsOnTargets=“B;C;D“ >
<OnError Targets=“OnFailure“ />
<Target Name=“OnFailure“ >
<Target Name=“OnSuccess“ >
Although this technique isn’t as intuitive as the NAnt solution, it does work.