我正在尝试使用 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)
如何为构建服务器引用或包含这些目标?它在 VS2017 中构建良好。我花了一天多的时间打猎,找不到关于这个问题的任何信息。
最佳答案
感谢 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)
编辑: MSBuild@1 任务也有效。
关于在 Azure DevOps 上构建 sqlproj,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53473804/