I don't use Post Build events in my Visual Studio solutions very often since I prefer to code this directly into MSBuild as part of my Continuous Integration build process usually run by a CI Server such as Jetbrains TeamCity or Team Foundation Build.
However, since I work on a wide variety of projects as part of my consultancy, I frequently encounter projects which still leverage Visual Studio Post Build events.
A large number of Visual Studio projects have a Post Build event which redirects the output to another directory on the file system and may even include a set of commands needed to create the correct target directory structure.
The problem with this approach is using standard command line commands such as mkdir will emit errors if a directory already exists, thus causing Visual Studio to raise an error if a particular command in the Post Build event fails even though it may have worked just fine overall.
So, how do you handle this problem?
Well, using the capabilities of MSBuild, you can modify the Visual Studio project file to ignore these Post Build event error messages!
The solution provided here is by far my favorite solution to this problem: http://blogs.msdn.com/b/astebner/archive/2006/08/08/691849.aspx
It overrides the PreBuildEvent (or PostBuildEvent) target in order to ignore the exit codes or continue the Post Build event even if an error occurs. Alternatively, you can even do both!
Once you include this target in your relevant Visual Studio project files, the Post Build event error messages you are encountering should disappear!
However, since I work on a wide variety of projects as part of my consultancy, I frequently encounter projects which still leverage Visual Studio Post Build events.
A large number of Visual Studio projects have a Post Build event which redirects the output to another directory on the file system and may even include a set of commands needed to create the correct target directory structure.
The problem with this approach is using standard command line commands such as mkdir will emit errors if a directory already exists, thus causing Visual Studio to raise an error if a particular command in the Post Build event fails even though it may have worked just fine overall.
So, how do you handle this problem?
Well, using the capabilities of MSBuild, you can modify the Visual Studio project file to ignore these Post Build event error messages!
The solution provided here is by far my favorite solution to this problem: http://blogs.msdn.com/b/astebner/archive/2006/08/08/691849.aspx
It overrides the PreBuildEvent (or PostBuildEvent) target in order to ignore the exit codes or continue the Post Build event even if an error occurs. Alternatively, you can even do both!
Once you include this target in your relevant Visual Studio project files, the Post Build event error messages you are encountering should disappear!
No comments:
Post a Comment