Cake,VS2017,.NET Core 2.0和构建SQL项目

时间:2018-01-30 10:54:15

标签: msbuild sqlproj

我正在尝试构建一个.NET Core 2.0解决方案,该解决方案有一个空的空SQL Server项目,但是出现了这个错误:

@Override
public RepositorySearchesResource process(RepositorySearchesResource resource) {
  TemplateVariable earlyPickupDate = new TemplateVariable(EARLY_PICKUP_DATE_PARAM, TemplateVariable.VariableType.REQUEST_PARAM, "Selects all records with earlyPickupDate >= to the value specified.");
  TemplateVariable status = new TemplateVariable(STATUS_PARAM, TemplateVariable.VariableType.REQUEST_PARAM_CONTINUED, "Specifies the order status.");
  TemplateVariable costCenter = new TemplateVariable(COST_CENTER_PARAM, TemplateVariable.VariableType.REQUEST_PARAM_CONTINUED, "Specified the cost center to return orders for.");
  TemplateVariables vars = new TemplateVariables(earlyPickupDate, status, costCenter);
  UriTemplate uri = new UriTemplate(resource.getId().getHref() + "exceptionsByDate", vars);
  resource.add(new Link(uri, "exceptionsByDate"));
  return resource;
}

如果我像这样直接调用MSBuild,解决方案可以在VS2017中正确构建,也可以从命令行构建: “C:\ Program Files(x86)\ Microsoft Visual Studio \ 2017 \ Professional \ MSBuild \ 15.0 \ Bin \ msbuild.exe”MySolution.sln / t:build / fl /flp:logfile=MyProjectOutput.log;verbosity=diagnostic < / p>

Cake脚本如下所示:

MyDb.sqlproj(57,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\2.1.4\Microsoft\VisualStudio\v11.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 个答案:

答案 0 :(得分:-1)

Net Core不支持SQL项目,因此您应该使用MSBuild而不是DotNetCoreBuild。 像这样:

Task("Build")
    .IsDependentOn("RestoreNuGetPackages")
    .IsDependentOn("SetVersion")
    .Does(() =>
{
   Information("Running DotNetCoreBuild");
   MSBuild("../MySolution.sln",
    settings =>
      settings
        .SetConfiguration(configuration)
        .SetVerbosity(Verbosity.Minimal));          
});