private async void OpenLogFile(string filePath) { if (!File.Exists(filePath)) { return; } DisplayBuild(null); this.logFilePath = filePath; SettingsService.AddRecentLogFile(filePath); UpdateRecentItemsMenu(); Title = filePath + " - " + DefaultTitle; var progress = new BuildProgress(); progress.ProgressText = "Opening " + filePath + "..."; SetContent(progress); bool shouldAnalyze = true; var stopwatch = Stopwatch.StartNew(); Build build = await System.Threading.Tasks.Task.Run(() => { try { return(Serialization.Read(filePath)); } catch (Exception ex) { ex = ExceptionHandler.Unwrap(ex); shouldAnalyze = false; return(GetErrorBuild(filePath, ex.ToString())); } }); if (build == null) { build = GetErrorBuild(filePath, ""); shouldAnalyze = false; } if (shouldAnalyze) { progress.ProgressText = "Analyzing " + filePath + "..."; await System.Threading.Tasks.Task.Run(() => BuildAnalyzer.AnalyzeBuild(build)); } progress.ProgressText = "Rendering tree..."; await Dispatcher.InvokeAsync(() => { }, DispatcherPriority.Loaded); // let the progress message be rendered before we block the UI again DisplayBuild(build); var elapsed = stopwatch.Elapsed; if (currentBuild != null) { currentBuild.UpdateBreadcrumb($"Load time: {elapsed}"); } }
public Task <Build> BuildAndGetResult(BuildProgress progress) { var msBuildFile = SettingsService.GetMSBuildFile(); var isLibraryMsBuild = msBuildFile?.EndsWith(".dll", StringComparison.OrdinalIgnoreCase); msBuildFile = msBuildFile.QuoteIfNeeded(); var postfixArguments = GetPostfixArguments(); // the command line we pass to Process.Start doesn't need exec file var commandLine = $"{projectFilePath.QuoteIfNeeded()} {customArguments} {postfixArguments}"; commandLine = isLibraryMsBuild == true ? $"{msBuildFile} {commandLine}" : commandLine; var fileExe = isLibraryMsBuild == true ? "dotnet " : msBuildFile; // the command line we display to the user should contain the full path to msbuild file progress.MSBuildCommandLine = $"{fileExe} {commandLine}"; return(System.Threading.Tasks.Task.Run(() => { try { var processStartInfo = new ProcessStartInfo(fileExe, commandLine); processStartInfo.WorkingDirectory = Path.GetDirectoryName(projectFilePath); var process = Process.Start(processStartInfo); process.WaitForExit(); var logFilePath = Path.Combine(currentDirectory, "msbuild.binlog"); var build = Serialization.Read(logFilePath); //File.Delete(logFilePath); //var projectImportsZip = Path.ChangeExtension(logFilePath, ".ProjectImports.zip"); //if (File.Exists(projectImportsZip)) //{ // File.Delete(projectImportsZip); //} return build; } catch (Exception ex) { ex = ExceptionHandler.Unwrap(ex); var build = new Build(); build.Succeeded = false; build.AddChild(new Message() { Text = "Exception occurred during build:" }); build.AddChild(new Error() { Text = ex.ToString() }); return build; } })); }
public Task <Build> BuildAndGetResult(BuildProgress progress) { var msbuildExe = SettingsService.GetMSBuildExe(); var postfixArguments = GetPostfixArguments(); // the command line we pass to Process.Start doesn't need msbuild.exe var commandLine = $"{QuoteIfNeeded(projectFilePath)} {customArguments} {postfixArguments}"; // the command line we display to the user should contain the full path to msbuild.exe progress.MSBuildCommandLine = $"{QuoteIfNeeded(msbuildExe)} {commandLine}"; return(System.Threading.Tasks.Task.Run(() => { try { var arguments = commandLine; var processStartInfo = new ProcessStartInfo(msbuildExe, arguments); processStartInfo.WorkingDirectory = Path.GetDirectoryName(projectFilePath); var process = Process.Start(processStartInfo); process.WaitForExit(); var build = Serialization.Read(logFilePath); File.Delete(logFilePath); var projectImportsZip = Path.ChangeExtension(logFilePath, ".ProjectImports.zip"); if (File.Exists(projectImportsZip)) { File.Delete(projectImportsZip); } return build; } catch (Exception ex) { ex = ExceptionHandler.Unwrap(ex); var build = new Build(); build.Succeeded = false; build.AddChild(new Message() { Text = "Exception occurred during build:" }); build.AddChild(new Error() { Text = ex.ToString() }); return build; } })); }
private async void OpenLogFile(string filePath) { if (!File.Exists(filePath)) { return; } DisplayBuild(null); this.logFilePath = filePath; SettingsService.AddRecentLogFile(filePath); UpdateRecentItemsMenu(); Title = DefaultTitle + " - " + filePath; var progress = new BuildProgress(); progress.ProgressText = "Opening " + filePath + "..."; SetContent(progress); bool shouldAnalyze = true; Build build = await System.Threading.Tasks.Task.Run(() => { try { return(Serialization.Read(filePath)); } catch (Exception ex) { ex = ExceptionHandler.Unwrap(ex); shouldAnalyze = false; return(GetErrorBuild(filePath, ex.ToString())); } }); if (build == null) { build = GetErrorBuild(filePath, ""); shouldAnalyze = false; } if (shouldAnalyze) { progress.ProgressText = "Analyzing " + filePath + "..."; await System.Threading.Tasks.Task.Run(() => BuildAnalyzer.AnalyzeBuild(build)); } DisplayBuild(build); }