如何使用 winform c# 执行 msbuild.exe 命令?

how to execute msbuild.exe command using winform c#?

我想在单击按钮时从 winform c# 执行 msbuild.exe 命令

private void button2_Click(object sender, EventArgs e)
{
    // get the reg key
    RegistryKey regKey;
    regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\MSBuild\ToolsVersions");

    // get the CurrentInstallFolder
    string msBuildToolsPath = (string)regKey.GetValue("MSBuildToolsPath"); 

我已经更新了我的代码,使用下面的代码来执行 msbuild 它正在工作,但是一旦所有执行屏幕就关闭了,我应该看到屏幕打开

var solutionFile = item.ToString();
var msbuildPath = msBuildToolsPath;

var startInfo = new ProcessStartInfo()
{
    CreateNoWindow = true,
    Arguments = String.Format("\"{0}\" /nologo", solutionFile),
        FileName = Path.Combine(msbuildPath, "msbuild.exe")
};

var proc = Process.Start(startInfo);
proc.WaitForExit();
  System.Diagnostics.Process.Start(@"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe");