Am trying to call SQlPackage from a windowsfroms project using System.Diagnostics.process
Below is the code snippet i am using to call Sqlpacakage with dacpac path and connection string as argument
ProcessStartInfo procStartInfo = new ProcessStartInfo();
procStartInfo.FileName = @"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\130\sqlpackage.exe";
procStartInfo.Arguments = @"/Action:Publish /SourceFile:""C:\Myfiles\Samples\TestDatabse\Snapshots\TestDatabse_20191201_12 - 59 - 10.dacpac"" /TargetConnectionString:""Data Source = Server; Integrated Security = False; Initial Catalog = AdventureWorksDW2014; User ID = User; Password = Password; "" /p:DropObjectsNotInSource=False /p:BlockOnPossibleDataLoss=True /dsp:""C:\sqlOutput\Deploy.sql""";;
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
using (Process process = new Process())
{
process.StartInfo = procStartInfo;
process.Start();
process.WaitForExit();
StreamReader reader = process.StandardOutput;
string output = reader.ReadToEnd();
}
when i execute the snippet the process is not waiting till the Deployment of database. if i read the output am getting the First line of the output like Publishing to database 'AdventureWorksDW2014' on server ''.the process is getting exited after this and the database is not getting updated to given dACPAC.
is there any suggested way where i can wait till the deployment of given DACPAC is done and DACPAC gets published in server.