Visual Studio pre-build action to skip project build based on condition

1k views Asked by At

In a VS 2008 solution, I have several projects. I run the build on the entire solution with msbuild. Based on the existence of a file on the disk, I want to skip the build for one of the projects. How can I achieve this? Is there a way to use a prebuild action to skip the project build?

1

There are 1 answers

0
Sergio Rykov On

PreBuildEvent is used to call custom script in OutDir. There is no special flags to skip building. I know several ways to hack build system and get needed behaviour, but it's not cosher.

1) First of all you can create two solutions (with and without that project). On top of that you can easily create a script which will check existence of the file and call MSBuild to build one or another.

2) You can remove the project from sln, add new simple project (let's say dll) and check existence of the file in BeforeBuild action and call MSBuild to build your custom project. Or you can add this behaviour to the one of the projects in that sln.