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.