Reputation: 6579
I'm trying to create an Integration Test. For this I want a clean database. I also have a Database Project which contains the tables and scripts that would give me a clean installation.
As such, I have tried to build this with Microsoft.Build framework. Here is the code:
var props = new Dictionary<string, string> {
{ "UpdateDatabase", "True" },
{ "PublishScriptFileName", "schema-update.sql" },
{ "SqlPublishProfilePath", "../../../../MyProj.Database/MyProj.Database.publish.xml" }
};
//The relative path starts in the bin folder so I have to go back a few.
var projectPath = "../../../../MyProj.Database/MyProj.Database.sqlproj";
var result = BuildManager.DefaultBuildManager.Build(
new BuildParameters{ Loggers = new [] { new ConsoleLogger() }},
new BuildRequestData(new ProjectInstance(projectPath, props, null), new [] { "Publish" } )
);
return result.OverallResult == BuildResultCode.Success;
When I run this code, I get the following error:
The imported project \"C:\Users\Me\.nuget\packages\microsoft.testplatform.testhost\15.8.0\lib\netstandard1.5\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. C:\_websites\Projects\MyProj\MyProj.Database\MyProj.Database.sqlproj
Now the first path doesn't exist. There is is indeed the netstandard1.5
folder, but no Microsoft
folder under it. The second path, the one to my project does exist and what it lists there is correct. If I copy and past the path, I get to my project.
Also, if I manually publish the database project, there are no problems.
I'm wondering if there is maybe a package I'm missing to make this work? I have Microsoft.Build
and Microsoft.Build.Framework
installed.
Upvotes: 4
Views: 7234
Reputation: 4929
I was getting the same error message trying to build in TFS.
2019-07-15T12:29:03.3583684Z C:\vsts-agent-win-x64-2.136.1\_work\4\s\Database\ccc.SqlServer.Database\ccc.SqlServer.Database.sqlproj(126,3): error MSB4019: The imported project "C:\vsts-agent-win-x64-2.136.1\_work\_tool\dncs\2.2.203\x64\sdk\2.2.203\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.
2019-07-15T12:29:03.9586915Z
2019-07-15T12:29:03.9588040Z Build FAILED.
2019-07-15T12:29:03.9605507Z
2019-07-15T12:29:03.9611553Z C:\vsts-agent-win-x64-2.136.1\_work\4\s\Database\ccc.SqlServer.Database\ccc.SqlServer.Database.sqlproj(126,3): error MSB4019: The imported project "C:\vsts-agent-win-x64-2.136.1\_work\_tool\dncs\2.2.203\x64\sdk\2.2.203\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.
2019-07-15T12:29:03.9612755Z 0 Warning(s)
2019-07-15T12:29:03.9613175Z 1 Error(s)
2019-07-15T12:29:03.9625235Z
2019-07-15T12:29:03.9630668Z Time Elapsed 00:00:04.67
2019-07-15T12:29:04.0221095Z ##[error]Error: C:\vsts-agent-win-x64-2.136.1\_work\_tool\dncs\2.2.203\x64\dotnet.exe failed with return code: 1
My problem ended up being user error.
The TFS build definition was setup to only build *.csproj
files. However, one of the C# projects had an unnecessary dependency on a .sqlproj
project. Removing the dependency allowed the build to succeed.
(I think if we were trying to build .sqlproj
files then this answer would be useful, outlining that the SQL Server Data Tools need to be installed on all build agents.)
Upvotes: 1