代码之家  ›  专栏  ›  技术社区  ›  Lex Webb

使用MSBuild与VS2017构建SSDT项目失败

  •  1
  • Lex Webb  · 技术社区  · 8 年前

    我正在尝试建立持续集成。sqlproj SSDT项目在我们的windows server 2016服务器上。

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

    我目前面临的问题是,安装的ms build tools和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 Microsoft.Build.Utilities.Core dll是v14: Microsoft.Build.Conversion.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL

    我这里丢了什么钥匙吗?看来,安装build tools 2017实际上并没有更新GAC并注册正确的DLL。

    2 回复  |  直到 8 年前
        1
  •  6
  •   Martin Ullrich    8 年前

    不要使用msbuild。exe包含在中。NET框架( 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
    

        2
  •  0
  •   ccoutinho    6 年前

    我在CI/CD管道上构建SQL Server项目时遇到了这个问题。Azure DevOps上的预构建构建任务都不适合我。我通过避免向解决方案中添加SQL Server项目来解决这个问题。

    我通过使用 MSBuild SDK ,能够生成SQL Server数据层应用程序包( .dacpac )从SQL脚本集。通过将第二个项目添加到解决方案中,我设法继续利用通过Visual Studio上的SQL Server对象浏览器将项目链接到实时数据库的优势。我对此做了更详细的解释 answer .

    推荐文章