Visual Studio – Dynamic Post-Build Event Setup

buildsvisual studio

I am building a video server application that has multiple projects in Visual Studio. One project, the video server project, needs to call a shell script to generate documentation. This works fine when you build the video server project, because the script is simply

cd "$(SolutionDir)"
start documentationgenerator

However, there is also an SDK project that, when built, also builds the video server project. However, when it does this, it does not know where the shell script is, since it tries to use the SDK Project's Solution Directory.

  • SDK Project
  • Video Server Project
    • shell script

So the question is: how do I make the SDK Project find the Video Server Project? I checked the MSBuild properties and there are no properties that seem to deal with 'nested' projects.

Best Answer

(Edited in response to comments)

The trick to getting a consistent build when reusing projects across solutions is to try and identify a known, common root and work relative to there. In your place the common root would seem to be the video server project.

Instead of using $(SolutionDir) in your video project (post build event?), try and do something with the video servers $(ProjectDir) - that will always be set no matter what solution it lives in. From your example something like this should resolve to the same place as $(SolutionDir) - you'll probably have to play with quotes and leading\trailing backslashes - I can't remember what the VS macros do with those now.

cd "$(ProjectDir)..\"
start DocumentationBuilder