Following is the code using which you can perform automated
compilation of visual studio solutions through C#. First of all let’s retrieve
the executing assembly path to write the output log of build activity performed
using C#.
//retrieve assembly execution path
string assemblyExecutionPath =
System.Reflection.Assembly.GetExecutingAssembly().Location;
string
logFilePath = assemblyExecutionPath.Remove(assemblyExecutionPath.LastIndexOf("\\") + 1) + "build.log";
Let’s create a collection to hold the output –
OutputHeaderRow = new List<string>();
OutputItemRow = new
List<string>();
Let’s say the path
of the solution to build using C# code is present in following variable - string
artifactPath = @"C:\Kunal_AppDev\New folder\Test Data Solution\ MySolution.sln"
Following is the remaining
complete code –


