msbuild - 使用 MSBuild 通过 VS2017 构建 SSDT 项目失败

标签 msbuild visual-studio-2017 sql-server-data-tools

我正在尝试在我们的 Windows Server 2016 服务器上设置 .sqlproj SSDT 项目的持续集成。

为了做到这一点,我在服务器上安装了 VS2017 和 SSDT 工具,以获得所需的工具。我还安装了 MS 构建工具 2017。

我目前遇到的问题是安装的 ms 构建工具和 ssdt 的版本似乎不匹配。

我用来运行构建的命令如下:

C:\\Windows\Microsoft.NET\\Framework64\\v4.0.30319\\MSBuild.exe /p:VisualStudioVersion=15.0 /property:MSBuildExtensionsPath="C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\MSBuild\\" /property:VsInstallRoot="C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\" DPAP-SQL-Slim.sln

那里传递的两个开关用于设置 .sqlproj 文件在通过 Visual Studio 运行时期望找到的两个环境参数。这是因为 MSBuild 默认不提供它们。

我目前得到的错误如下:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets(477,5): error MSB4062: The "SqlModelResolutionTask" task could not be loaded from the assembly C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\Common7\IDE\Extensions\Microsoft\SQLDB\Dac\140\Microsoft.Data.Tools.Schema.Tasks.Sql.dll. Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

现在,我可以通过运行命令看到:gacutil /l在 VS2017 命令提示符中明显安装了 Microsoft.Build.Utilities.Core 的版本dll 是 v14:Microsoft.Build.Conversion.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL

我是不是漏掉了一些关键的东西?似乎安装构建工具 2017 实际上并未更新 GAC 并注册正确的 DLL。

最佳答案

请勿使用 .NET Framework 中包含的 msbuild.exe (C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe)。它很旧,不支持较新 msbuild 版本的某些功能。

始终使用随 visual studio 或构建工具安装的 MSBuild 版本。根据安装的 VS 版本,这可能是

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe

从 VS 2017 开始,MSBuild 也不会在系统范围内安装,但可以并排安装许多版本(例如 VS 2017 预览版、构建工具/企业/社区等不同版本),这就是为什么您不会在 GAC 中找到这些 MSBuild 程序集。

关于msbuild - 使用 MSBuild 通过 VS2017 构建 SSDT 项目失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47440260/

相关文章:

visual-studio-2008 - Visual Studio 2013 + Business Intelligence SSDT 中缺少 Reporting Server 模板

tfsbuild - 使用 TFS 构建触发时抑制 Powershell 中的 sqlpackage.exe 警告/错误

tfs - 如何让 Team Build 显示 xUnit.net 测试套件的测试结果和覆盖率?

c# - 如何诊断警告 MSB3277 : Found conflicts between different versions of the same dependent assembly that could not be resolved

c# - Xamarin.iOS 未处理错误启动软调试器 :System. NotSupportedException

sql-server - 在SSIS中使用对象数据类型变量作为表名进行查询

msbuild - 将自定义元数据从另一个项目组添加到已定义的项目组

MSBuild 4 和 MSDeploy 命令行

visual-studio - 如何为 Visual Studio 2017 RC CMake 项目设置工作目录

c# - Visual Studio 的删除未使用的引用安全吗?