$(SolutionDir)MSBuild属性不正确当运行Sandcastle帮助文件生成器通过CMD [英] $(SolutionDir) MSBuild property incorrect when running Sandcastle Help File Builder via CMD

查看:506
本文介绍了$(SolutionDir)MSBuild属性不正确当运行Sandcastle帮助文件生成器通过CMD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用Windows CMD运行Sandcastle帮助文件生成器项目文件(例如 myproject.shfbproj )时,我遇到一个恼人的问题: $ SolutionDir)具有与 $(ProjectDir)相同的值,这意味着项目文档源将无法正确构建,因为我添加自定义已经使用 $(SolutionDir)的目标。



如果我从Visual Studio构建整个Sandcastle帮助文件生成器



我使用以下命令(从存储项目的目录执行):

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

有没有解决方法?

解决方案

虽然@ m0sa指出了一个非常明显的事实(因为我正在构建Sandcastle帮助文件构建器项目,没有实际的解决方案目录),问题也发生在TFS构建期间,构建解决方案

现在我已经设法使用一个讨厌的解决方法来解决这个问题:添加一个 SolutionDir 属性在每个需要作为文档项目的一部分构建的C#项目中:

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

由于我的解决方案文件将始终位于Sandcastle帮助文件生成器项目目录的父目录中,我的案例这个解决方法工作...



现在作为文档源引用的项目能够导入自定义项目,我在Visual Studio构建或外部定义常见的MSBuild属性:

 < Import Project =$(SolutionDir)MSBuild\Common.properties/> 


When I run 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 uses $(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 any workaround for this?

解决方案

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 resides the so-called documentation project.

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 diretory, 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" />

这篇关于$(SolutionDir)MSBuild属性不正确当运行Sandcastle帮助文件生成器通过CMD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆