5 November, 2010
0 Comments
1 category
If you want to build a Microsoft Visual Studio solution file and show the output during build, you can use the following code:
/// <summary> /// Rebuilds the Microsoft Visual Studio Solution in the given configuration. /// - Shows build output during build /// </summary> public void Rebuild() { string logFilePath = "build.log"; using (Process process = Process.Start( @"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe", string.Format(@"""{0}"" /Rebuild Release /out {1}", @"C:\Projects\Main.sln", logFilePath))) { using (FileStream fs = new FileStream( logFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (StreamReader sr = new StreamReader(fs)) { while (!process.HasExited) { while (!sr.EndOfStream) { Console.WriteLine(sr.ReadLine()); } Thread.Sleep(1000); } } } } Console.WriteLine("Rebuild completed"); }
Tags: C#Visual Studio
Category: Uncategorized