public async Task RunAsync(bool isDryRun) { try { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(_package.DisposalToken); var toolWindow = (BenchmarkTreeWindow)_package.FindToolWindow(typeof(BenchmarkTreeWindow), 0, false); BenchmarkTreeNode selectedNode = toolWindow.SelectedItem; var dte2 = (DTE2)Package.GetGlobalService(typeof(SDTE)); EnvDTE.Project project = GetProject(dte2, selectedNode.ProjectName); if (project == null) { return; } var propertyProvider = await CreateProjectPropertyProviderAsync(project.Name); try { if (!propertyProvider.IsOptimized) { await UIHelper.ShowErrorAsync(_package, "The current build configuration does not have the \"Optimize code\" flag set and is therefore not suitable for running Benchmarks.\r\n\r\nPlease enable the the \"Optimize code\" flag (under Project Properties -> Build) or switch to a non-debug configuration (e.g. 'Release') before running a Benchmark."); return; } } catch (Exception) { } string configurationName = project.ConfigurationManager.ActiveConfiguration.ConfigurationName; dte2.Solution.SolutionBuild.BuildProject(configurationName, project.UniqueName, true); if (dte2.Solution.SolutionBuild.LastBuildInfo != 0) { return; } var runParameters = new RunParameters { OutputPath = propertyProvider.OutputPath, ProjectPath = propertyProvider.ProjectPath, Runtime = propertyProvider.TargetRuntime, AssemblyPath = propertyProvider.GetOutputFilename(), IsDryRun = isDryRun, SelectedNode = selectedNode }; BenchmarkRunController runController = new BenchmarkRunController(runParameters, GetOptions()); await runController.RunAsync(); } catch (Exception ex) { await UIHelper.ShowErrorAsync(_package, ex.Message); } }
public async Task CopyCommandlineToClipboardAsync() { try { BenchmarkRunController runController = await CreateBenchmarkRunControllerAsync(false); if (runController == null) { return; } runController.CopyCommandlineToClipboard(); } catch (Exception ex) { await UIHelper.ShowErrorAsync(_package, ex.Message); } }
public async Task RunAsync(bool isDryRun) { try { BenchmarkRunController runController = await CreateBenchmarkRunControllerAsync(isDryRun); if (runController == null) { return; } await runController.RunAsync(); } catch (Exception ex) { await UIHelper.ShowErrorAsync(_package, ex.Message); } }