public static async Task <bool> Compile(string trunkDir, bool x64, IProgress <string> progress, CancellationToken token) { return(await Task.Run(() => { string args; if (x64) { args = String.Format("\"{0}\\TrinityCore.sln\" /t:Build /p:Configuration=Release /p:Platform=x64", trunkDir); } else { args = String.Format("\"{0}\\TrinityCore.sln\" /t:Build /p:Configuration=Release /p:Platform=Win32", trunkDir); } string cpath = VisualStudio.GetCompilerPath(); var proc = ProcessHelper.StartProcess(cpath, Path.GetDirectoryName(cpath), args); if (proc == null) { return false; } int id = proc.Id; proc.EnableRaisingEvents = true; proc.BeginOutputReadLine(); proc.OutputDataReceived += (sender, e) => { Thread.Sleep(50); progress.Report(e.Data); if (token.IsCancellationRequested) { if (ProcessHelper.ProcessExists(id)) { proc.Kill(); proc.Dispose(); } } }; proc.WaitForExit(); return true; }, token)); }
public static async Task <bool> Clean(string trunkDir, bool x64, IProgress <string> progress, CancellationToken token) { return(await Task.Run(() => { string args = String.Empty; if (x64) { args = String.Format("\"{0}\\TrinityCore.sln\" /t:Clean", trunkDir); } else { args = String.Format("\"{0}\\TrinityCore.sln\" /t:Clean", trunkDir); } string cpath = VisualStudio.GetCompilerPath(); var proc = ProcessHelper.StartProcess(cpath, Path.GetDirectoryName(cpath), args); if (proc == null) { return false; } proc.EnableRaisingEvents = true; proc.BeginOutputReadLine(); proc.OutputDataReceived += (sender, e) => { progress.Report(e.Data); if (token.IsCancellationRequested) { proc.Kill(); proc.Dispose(); } }; proc.WaitForExit(); return true; }, token)); }