Frage

I'm making Visual Studio package where i start devenv.exe and try to build other solution.I need to get building output in realtime, so user can see buiding progress(output), but i don't know how to do it and if it's even possible.

I tried such way :

            string rebuildLog = string.Empty;
            string logFileName = System.IO.Path.GetTempFileName();

            System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
            psi.FileName = @"devenv.exe";
            psi.Arguments = "\"" + config.DmsPath + "\"" + @" /rebuild" + " Release|x64 " +" /out " + logFileName;

            System.Diagnostics.Process process = new System.Diagnostics.Process();
            process.StartInfo = psi;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.UseShellExecute = false;

            process.Start();

            while (!process.StandardOutput.EndOfStream)
            {
                string line = process.StandardOutput.ReadLine();
                MessageBox.Show(line); // just to see if it works. It should go to log form
            }


            rebuildLog = GetRebuildLog(logFileName);

And rebuildLog has output.

Can anybody help ?

War es hilfreich?

Lösung

I found answer. devenv.exe doesn't write simple console output, so i had to change

psi.FileName = @"devenv.exe"; to psi.FileName = @"devenv.com"; and it worked.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top