/// <summary> /// This function is the callback used to execute a command when the a menu item is clicked. /// See the Initialize method to see how the menu item is associated to this function using /// the OleMenuCommandService service and the MenuCommand class. /// </summary> private async Task RegisterModifyPluginCallbackAsync(object sender, EventArgs args) { try { var session = Math.Abs(DateTime.Now.ToString(CultureInfo.CurrentCulture).GetHashCode()); Status.Update($">>>>> Starting new session: {session} <<<<<"); var selected = DteHelper.GetSelectedProjects().ToArray(); if (!selected.Any()) { throw new UserException("Please select a project first."); } foreach (var project in selected) { Status.Update($">>> Processing project: {DteHelper.GetProjectName(project)} <<<"); DteHelper.SetCurrentProject(project); AssemblyHelper.BuildProject(); await RegisterModifyPluginAsync(); Status.Update($"^^^ Finished processing project: {DteHelper.GetProjectName(project)} ^^^"); } Status.Update($"^^^^^ Finished session: {session} ^^^^^"); } catch (UserException e) { VsShellUtilities.ShowMessageBox(ServiceProvider.GlobalProvider, e.Message, "Error", OLEMSGICON.OLEMSGICON_WARNING, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); } catch (Exception e) { var error1 = "[ERROR] " + e.Message + (e.InnerException != null ? "\n" + "[ERROR] " + e.InnerException.Message : ""); Status.Update(error1); Status.Update(e.StackTrace); Status.Update("Unable to register assembly, see error above."); var error2 = e.Message + "\n" + e.StackTrace; MessageBox.Show(error2, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { Status.Update(">>>>> DONE! <<<<<"); } }