Ambuj
Ambuj

Reputation: 455

Cake, VS2017, .NET Core 2.0 and building SQL project

I'm trying to build a .NET Core 2.0 solution which has got a blank empty SQL Server project but getting this error:

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.

The solution builds correctly in VS2017 and also from command line if I call MSBuild directly like this: "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

Cake script looks like this:

Task("Build")
    .IsDependentOn("RestoreNuGetPackages")
    .IsDependentOn("SetVersion")
    .Does(() =>
{
   Information("Running DotNetCoreBuild");
    DotNetCoreBuild("../MySolution.sln", new DotNetCoreBuildSettings { 
        Configuration = configuration
   });
});

Any ideas why am I getting that error please? Thanks

Upvotes: 2

Views: 485

Answers (1)

Janis
Janis

Reputation: 19

SQL projects are not supported by Net Core so you should use MSBuild instead of DotNetCoreBuild. Something like this:

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

Upvotes: 0

Related Questions