Can´t build .net core project with a database project. Error MSB4019
Asked Answered
S

2

6

I have a new .net Core 2.0 Web API project (In Visual Studio 2017 Version 15.3.5) where I can´t build the solution if I add a new database project.

error MSB4019: The imported project "C:\Program Files\dotnet\sdk\2.0.0\Microsoft\VisualStudio\v11.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

I have tried all kinds of solutions

  • Installed almost everything missing from the Visual Studio Installer
  • Installed Visual Studio Build Tools 2017
  • Repaired Visual Studio
  • Without luck I tried to find Microsoft.Data.Tools.Schema.SqlTasks.targets file on C:\ to the add reference to it in the project file (I then don´t know if that works while building the solution in VSTS).

So why can I add a database project to a normal API project and everything works just fine but not to a .net core one?

Do database projects not work with .net Core? I have searched for information on this but sorry I just can´t find it.

I´m not sure what to do. Hope somebody can help.

Stepchild answered 26/9, 2017 at 16:36 Comment(0)
S
2

Ok I managed to find the Microsoft.Data.Tools.Schema.SqlTasks.targets file on my computer.

I then needed to unload the project and edit it

There I changed this line

<SSDTExists Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets')">True</SSDTExists>

to the hardcoded path of my file

<SSDTExists Condition="Exists('C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets')">True</SSDTExists>

And now it builds on my computer and on VSTS.

But why this is like this I don´t know.

Stepchild answered 26/9, 2017 at 21:18 Comment(0)
G
2

I was having the exact same issue building a SQL Server project on an Azure DevOps CI/CD pipeline, and locally on VS Code. On Azure DevOps none of the pre-built build tasks would work for me, and locally I could only compile the SQL Server project on Visual Studio, which was annoying. Your solution didn't work for me, after doing what you suggest, I would get a .dll missing error, related with the first error.

I solved this by avoiding to add a SQL Server project to the solution.

I achieved this by using an MSBuild SDK, capable of producing a SQL Server Data-Tier Application package (.dacpac) from the set of SQL scripts. By adding this second project to the solution, I managed to continue taking advantage of linking the project to a live database through SQL Server Object Explorer on Visual Studio. I gave a more detailed explanation about my implementation in this answer.

Garget answered 18/4, 2020 at 20:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.