在 Azure DevOps 上构建 sqlproj

Han*_*ood 11 build sqlproj azure-devops azure-pipelines

我正在尝试使用 Azure DevOps Pipelines 从 GitHub 构建我的 .NET Core 2.1 解决方案。它包含一个 SQL 项目,其 TargetFrameworkVersion 为v4.6.2. 这个项目总是无法构建。

Build FAILED.

/home/vsts/work/1/s/MySolution/MyDatabase/MyDatabase.sqlproj : warning NU1503: Skipping restore for project '/home/vsts/work/1/s/MySolution/MyDatabase/MyDatabase.sqlproj'. The project file may be invalid or missing targets required for restore. [/home/vsts/work/1/s/MySolution/MySolution.sln]
/home/vsts/work/1/s/MySolution/MyDatabase/MyDatabase.sqlproj(57,3): error MSB4019: The imported project "/usr/share/dotnet/sdk/2.1.403/Microsoft/VisualStudio/v15.0/SSDT/Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
1 Warning(s)
1 Error(s)
Run Code Online (Sandbox Code Playgroud)

如何为构建服务器引用或包含这些目标?它在 VS2017 中构建良好。我花了一天多的时间打猎,找不到关于这个问题的任何信息。

Han*_*ood 9

感谢Herman Cordes指导我的调查。

问题是所选的构建服务器。SSDT 是一个仅限 Windows 的包,因此我必须使用 Windows VM 而不是默认的 Ubuntu VM,并使用VSBuild@1任务而不是DotNetCoreCLI@2

azure-pipelines.yml

pool:
  vmImage: 'vs2017-win2016'

steps:
- task: VSBuild@1
  displayName: 'vsbuild $(buildConfiguration)'
  inputs:
    configuration: $(buildConfiguration)
Run Code Online (Sandbox Code Playgroud)

编辑:MSBuild@1任务也有效。