/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { var componentModel = await GetServiceAsync(typeof(SComponentModel)) as IComponentModel; componentModel.DefaultCompositionService.SatisfyImportsOnce(this); SolutionManager.AfterNuGetProjectRenamed += SolutionManager_NuGetProjectRenamed; Brushes.LoadVsBrushes(); // Add our command handlers for menu (commands must exist in the .vsct file) await AddMenuCommandHandlersAsync(); _dte = (DTE) await GetServiceAsync(typeof(SDTE)); _dteEvents = _dte.Events.DTEEvents; _dteEvents.OnBeginShutdown += OnBeginShutDown; if (SolutionManager.NuGetProjectContext == null) { SolutionManager.NuGetProjectContext = ProjectContext; } // when NuGet loads, if the current solution has some package // folders marked for deletion (because a previous uninstalltion didn't succeed), // delete them now. if (SolutionManager.IsSolutionOpen) { DeleteOnRestartManager.Value.DeleteMarkedPackageDirectories(ProjectContext); } ProjectRetargetingHandler = new ProjectRetargetingHandler(_dte, SolutionManager, this, componentModel); ProjectUpgradeHandler = new ProjectUpgradeHandler(this, SolutionManager); SolutionUserOptions.LoadSettings(); // This instantiates a decoupled ICommand instance responsible to locate and display output pane by a UI control UI.Commands.ShowErrorsCommand = new ShowErrorsCommand(this); _vsMonitorSelection = new AsyncLazy <IVsMonitorSelection>( async() => { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); // get the UI context cookie for the debugging mode var vsMonitorSelection = await GetServiceAsync(typeof(IVsMonitorSelection)) as IVsMonitorSelection; // get the solution not building and not debugging cookie var guidCmdUI = VSConstants.UICONTEXT.SolutionExistsAndFullyLoaded_guid; vsMonitorSelection.GetCmdUIContextCookie( ref guidCmdUI, out _solutionExistsAndFullyLoadedContextCookie); guidCmdUI = VSConstants.UICONTEXT.SolutionExistsAndNotBuildingAndNotDebugging_guid; vsMonitorSelection.GetCmdUIContextCookie( ref guidCmdUI, out _solutionNotBuildingAndNotDebuggingContextCookie); return(vsMonitorSelection); }, ThreadHelper.JoinableTaskFactory); }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { var componentModel = await GetServiceAsync(typeof(SComponentModel)) as IComponentModel; componentModel.DefaultCompositionService.SatisfyImportsOnce(this); SolutionManager.AfterNuGetProjectRenamed += SolutionManager_NuGetProjectRenamed; Styles.LoadVsStyles(); Brushes.LoadVsBrushes(); // Add our command handlers for menu (commands must exist in the .vsct file) await AddMenuCommandHandlersAsync(); _dte = (DTE) await GetServiceAsync(typeof(SDTE)); _dteEvents = _dte.Events.DTEEvents; _dteEvents.OnBeginShutdown += OnBeginShutDown; if (SolutionManager.NuGetProjectContext == null) { SolutionManager.NuGetProjectContext = ProjectContext; } // when NuGet loads, if the current solution has some package // folders marked for deletion (because a previous uninstalltion didn't succeed), // delete them now. if (SolutionManager.IsSolutionOpen) { DeleteOnRestartManager.Value.DeleteMarkedPackageDirectories(ProjectContext); } ProjectRetargetingHandler = new ProjectRetargetingHandler(_dte, SolutionManager, this, componentModel); ProjectUpgradeHandler = new ProjectUpgradeHandler(this, SolutionManager); SolutionUserOptions.LoadSettings(); // This instantiates a decoupled ICommand instance responsible to locate and display output pane by a UI control UI.Commands.ShowErrorsCommand = new ShowErrorsCommand(this); }