private void CompileCS(IConsole console, IStandardProject superProject, IStandardProject project, ISourceFile file,
string outputFile)
{
var startInfo = new ProcessStartInfo();
startInfo.FileName = Path.Combine(BaseDirectory, "Roslyn", "csc.exe");
if (Path.IsPathRooted(startInfo.FileName) && !System.IO.File.Exists(startInfo.FileName))
{
console.WriteLine("Unable to find compiler (" + startInfo.FileName + ") Please check project compiler settings.");
}
else
{
startInfo.WorkingDirectory = project.Solution.CurrentDirectory;
startInfo.Arguments = string.Format("{0} /out:{1} {2}", GetCSCCompilerArguments(superProject, project, file),
outputFile, file.Location);
// Hide console window
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.CreateNoWindow = true;
//console.WriteLine (Path.GetFileNameWithoutExtension(startInfo.FileName) + " " + startInfo.Arguments);
using (var process = Process.Start(startInfo))
{
process.OutputDataReceived += (sender, e) => { console.WriteLine(e.Data); };
process.ErrorDataReceived += (sender, e) =>
{
if (e.Data != null)
{
console.WriteLine();
console.WriteLine(e.Data);
}
};
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.WaitForExit();
}
}
}