带有VS 2017 BuildTools的MSBuild在生成时设置了错误的$(VSInstallDir)

时间:2018-09-11 23:29:48

标签: visual-studio msbuild visual-studio-2017 visual-studio-2017-build-tools

我发现最新的15.8.2 Visual Studio 2017构建工具有些奇怪的行为。安装工具并确保已安装所有工作负载和组件之后,我尝试使用以下命令从批处理文件构建主解决方案:

msbuild %~dp0\..\..\Master.sln /verbosity:quiet /ds /p:Configuration=Debug;Platform=x64 /m /fl1 /fl2 /fl3 /flp1:LogFile="%~dp0\MSBuild.log";Verbosity=normal /flp2:LogFile="%~dp0\ProjectWarnings.log";WarningsOnly /flp3:LogFile="%~dp0\ProjectErrors.log";ErrorsOnly

最早的一个项目失败,并出现以下错误:

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\TextTemplating\Microsoft.TextTemplating.targets(340,5): error : System.IO.FileNotFoundException: Could not find a part of the path 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\140\Microsoft.SqlServer.TransactSql.ScriptDom.dll'.

如果您会注意到,找不到的路径是在寻找“ Enterprise”目录,该目录显然不存在,因为我们安装了构建工具。问题的.dll在正确的目录中,即“ BuildTools”文件夹而不是“ Enterprise”文件夹中。在项目本身中,上面的.dll有以下行:

<HintPath>$(VSInstallDir)\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\140\Microsoft.SqlServer.TransactSql.ScriptDom.dll</HintPath>

在仅安装了构建工具且运行set的系统上查看开发人员命令提示符时,变量VSInstallDir正确映射到BuildTools文件夹:

VSINSTALLDIR=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\

我的问题是:MSBuild是从哪里获取“ Enterprise”目录的?我们不在任何项目中引用它,而是在必要时使用$(VSInstallDir)。我已经对整个BuildTools目录进行了grep提取,以引用“ Enterprise”,但在.targets文件或.props(或实际上是任何其他文件)中找不到任何表明该变量将解析为“ Enterprise”而不是“ BuildTools”的内容。

0 个答案:

没有答案