$(SolutionDir) MSBuild property incorrect when running Sandcastle Help File Builder via CMD

Matías Fidemraizer picture Matías Fidemraizer · Sep 7, 2015 · Viewed 19.4k times · Source

When I run the Sandcastle Help File Builder project file (for example, myproject.shfbproj) using Windows CMD, I get an annoying issue: $(SolutionDir) has the same value as $(ProjectDir), and this means that project documentation sources won't build correctly, because I'm adding custom targets which already use $(SolutionDir).

If I build the whole Sandcastle Help File Builder from Visual Studio it builds successfully.

I'm using the following command (executed from the directory where the project is stored):

"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" /p:Configuration=Development myproject.shfbproj

Is there a workaround for this?

Answer

m0sa picture m0sa · Sep 7, 2015

You only get the the correct $(SolutionDir) if you're building your solution (.sln file). The .shfbproj is a project file, and as such has no reference to its parent solution. You can try specifying the $(SolutionDir) in your command line explicitly:

msbuild /p:Configuration=Development /p:SolutionDir=MySolutionDir myproject.shfbproj

For reference: $(SolutionDir) and MSBuild