Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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.

share|improve this question
    
How about including a script that is called by the SDK project at compile/build that calls the script for the Video Server project? Assuming that the script for the Video Server project is always in the same place. –  Jamie Taylor Jun 18 '12 at 16:39
    
I don't think it is always in the same place - I'll have to check, but the Video Server Project is "included" in the SDK Project by linking, not by being in a specific folder –  SSumner Jun 18 '12 at 20:33
    
Can you update the post-build step to use $(MSBuildProjectDirectory) property instead? It should always point to the location of *.csproj file, no matter what solution it is called from. See msdn.microsoft.com/en-us/library/ms164309.aspx. –  Krzysztof Kozielczyk Jun 19 '12 at 6:49

1 Answer 1

up vote 2 down vote accepted

(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
share|improve this answer
    
I am using the MSBuild properties (that's how the Video Server project knows where it is). Unfortunately, because it is using $SolutionDir, when it is built by the SDK project, Visual Studio looks in the SDK project's Solution Directory, not the Video Server's. I'll edit the question to clarify –  SSumner Jun 18 '12 at 21:16
    
If both the projects live in the same VS solution, $SolutionDir should be the same for both builds. By SDK Project do you mean SDK Solution? Not to be picky but that's a very different thing :-) –  Marc Jun 18 '12 at 21:24
    
Both projects are different VS Solutions. One is just referenced by the other. I am using "SDK Project" to refer to the SDK of the project I am building (Video Server project is the Video Server and SDK Project is the Video Server SDK) –  SSumner Jun 18 '12 at 21:58
    
@SSumner: Marc is right, use a path relative to $(ProjectDir), that will work (I have done this before, too). +1. –  Doc Brown Jun 19 '12 at 15:00
    
So what you're saying is, un the Video Server solution post-build events, if I find the documentation generator based on the $(ProjectDir) macro, it will go to the Project Directory of the Video Server solution even if the Video Server is being built by another solution? –  SSumner Jun 19 '12 at 15:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.