Friday, September 15, 2006

Fun with Visual Studio 2005

What to do if a pre-build event fails for a Visual Studio 2005 project? Visual Studios default is to stop the build and report a failure right then and right there, without a nice, friendly checkbox to get the occasionally rabid programmer out of trouble.

Luckily, the .csproj file can be edited by hand (you will have to put up with the slight inconvenience of quitting VS, though) to override the default behavior by adding a new target definition before the closing </project> tag.
<Target
Name="PreBuildEvent"
Condition="'$(PreBuildEvent)'!=''"
DependsOnTargets="$(PreBuildEventDependsOn)">
<Exec
WorkingDirectory="$(OutDir)"
Command="$(PreBuildEvent)"
ContinueOnError="true" />
</Target>

How do I know these things? Well, I am smart, handsome and blessed with impeccable manners. Other than that, I know how to use google, and google pointed me to this fine article.

0 Comments:

Post a Comment

<< Home