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

我的未来我决定 提交于 2019-11-30 17:35:00
m0sa

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

Matías Fidemraizer

While @m0sa has pointed out a very obvious fact (since I'm building the Sandcastle Help File Builder project, there's no actual solution directory), the issue was also happening during a TFS Build when building the solution where the so-called documentation project resides.

For now I've managed to solve the issue using a nasty workaround: adding a SolutionDir property in each C# project that needs to be built as part of documentation project:

  <PropertyGroup>
    <SolutionDir>$([System.IO.Path]::GetDirectoryName($(MSBuildProjectDirectory)))\</SolutionDir>
  </PropertyGroup>

Since my solution file will always be located in the parent directory of Sandcastle Help File Builder project directory, in my case this workaround works...

Now referenced projects as documentation sources are able to import a custom project where I define common MSBuild properties, both in Visual Studio builds or external ones:

<Import Project="$(SolutionDir)MSBuild\Common.properties" />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!