void DoDeploy(string target) { this.Cursor = Cursors.WaitCursor; vForm = new viewlog(); bool res = true; res = UpdateData(); if (res) { try { string buildPath = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory(); buildPath = Path.Combine(buildPath, "MSBUILD.exe"); System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo = new ProcessStartInfo(buildPath, "\"" + sqlProjFile + "\" /t:" + target); p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; p.StartInfo.RedirectStandardOutput = true; p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived); p.Start(); p.BeginOutputReadLine(); p.WaitForExit(); string exitMsg = "succeeded"; if (p.ExitCode != 0) { exitMsg = "failed"; } this.Cursor = Cursors.Default; string viewMsg = string.Format("The deployment/drop {0}. Do you want to view the log file?", exitMsg); if (MessageBox.Show(viewMsg, "View Logfile", MessageBoxButtons.YesNo) == DialogResult.Yes) { vForm.ShowDialog(); } } catch (Exception ex) { MessageBox.Show("An unexpected error happened. The error is: " + ex.Message + ".", "Unexpected Error"); } finally { vForm.Dispose(); } } }
void DoDeploy(string target) { this.Cursor = Cursors.WaitCursor; vForm = new viewlog(); bool res = true; res = UpdateData(); if(res) { try { string buildPath = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory(); buildPath = Path.Combine(buildPath, "MSBUILD.exe"); System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo = new ProcessStartInfo(buildPath, "\"" + sqlProjFile + "\" /t:" + target); p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; p.StartInfo.RedirectStandardOutput = true; p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived); p.Start(); p.BeginOutputReadLine(); p.WaitForExit(); string exitMsg = "succeeded"; if (p.ExitCode != 0) exitMsg = "failed"; this.Cursor = Cursors.Default; string viewMsg = string.Format("The deployment/drop {0}. Do you want to view the log file?", exitMsg); if (MessageBox.Show(viewMsg, "View Logfile", MessageBoxButtons.YesNo) == DialogResult.Yes) { vForm.ShowDialog(); } } catch (Exception ex) { MessageBox.Show("An unexpected error happened. The error is: " + ex.Message + ".", "Unexpected Error"); } finally { vForm.Dispose(); } } }