/// <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 void Initialize() { base.Initialize(); Styles.LoadVsStyles(); Brushes.LoadVsBrushes(); AddIconCommand.Initialize(this); }
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { // Switches to the UI thread in order to consume some services used in command initialization await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); Brushes.LoadVsBrushes(); AddIconCommand.Initialize(this); }
/// <summary> /// Initialize all MEF imports for this package and also add required event handlers. /// </summary> private async Task InitializeMEFAsync() { _initialized = true; var componentModel = await GetServiceAsync(typeof(SComponentModel)) as IComponentModel; Assumes.Present(componentModel); componentModel.DefaultCompositionService.SatisfyImportsOnce(this); await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); SolutionManager.Value.AfterNuGetProjectRenamed += SolutionManager_NuGetProjectRenamed; Brushes.LoadVsBrushes(); _dte = (DTE) await GetServiceAsync(typeof(SDTE)); Assumes.Present(_dte); _dteEvents = _dte.Events.DTEEvents; _dteEvents.OnBeginShutdown += OnBeginShutDown; if (SolutionManager.Value.NuGetProjectContext == null) { SolutionManager.Value.NuGetProjectContext = ProjectContext.Value; } // 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 (await SolutionManager.Value.IsSolutionOpenAsync()) { await DeleteOnRestartManager.Value.DeleteMarkedPackageDirectoriesAsync(ProjectContext.Value); } ProjectRetargetingHandler = new ProjectRetargetingHandler(_dte, SolutionManager.Value, this, componentModel); ProjectUpgradeHandler = new ProjectUpgradeHandler(this, SolutionManager.Value); SolutionUserOptions.Value.LoadSettings(); }
/// <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); }
/// <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 void Initialize() { base.Initialize(); LoadSettings(); Styles.LoadVsStyles(); Brushes.LoadVsBrushes(); // *** // VsNuGetDiagnostics.Initialize( // ServiceLocator.GetInstance<IDebugConsoleController>()); // Add our command handlers for menu (commands must exist in the .vsct file) AddMenuCommandHandlers(); // IMPORTANT: Do NOT do anything that can lead to a call to ServiceLocator.GetGlobalService(). // Doing so is illegal and may cause VS to hang. _dte = (DTE)GetService(typeof(SDTE)); Debug.Assert(_dte != null); _dteEvents = _dte.Events.DTEEvents; _dteEvents.OnBeginShutdown += OnBeginShutDown; _outputConsoleLogger = new OutputConsoleLogger(this); SetDefaultCredentialProvider(); if (SolutionManager != null) { SolutionManager.SolutionOpened += (obj, ev) => { _nugetSettings = new NuGetSettings(); LoadNuGetSettings(); }; } _uiProjectContext = new NuGetUIProjectContext( _outputConsoleLogger, SourceControlManagerProvider, CommonOperations); if (SolutionManager.NuGetProjectContext == null) { SolutionManager.NuGetProjectContext = _uiProjectContext; } // 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) { DeleteOnRestart.DeleteMarkedPackageDirectories(_uiProjectContext); } // NOTE: Don't use the exported IPackageRestoreManager for OnBuildPackageRestorer. Exported IPackageRestoreManager also uses 'PackageRestoreManager' // but, overrides RestoreMissingPackages to catch the exceptions. OnBuildPackageRestorer needs to catch the exception by itself to populate error list window // Exported IPackageRestoreManager is used by UI manual restore, Powershell manual restore and by VS extensibility package restore OnBuildPackageRestorer = new OnBuildPackageRestorer(SolutionManager, PackageRestoreManager, this, SourceRepositoryProvider, Settings, new EmptyNuGetProjectContext()); ProjectRetargetingHandler = new ProjectRetargetingHandler(_dte, SolutionManager, this); ProjectUpgradeHandler = new ProjectUpgradeHandler(this, SolutionManager); LoadNuGetSettings(); // This initializes the IVSSourceControlTracker, even though _vsSourceControlTracker is unused. _vsSourceControlTracker = ServiceLocator.GetInstanceSafe<IVsSourceControlTracker>(); // This instantiates a decoupled ICommand instance responsible to locate and display output pane by a UI control var serviceProvider = ServiceLocator.GetInstanceSafe<System.IServiceProvider>(); UI.Commands.ShowErrorsCommand = new ShowErrorsCommand(serviceProvider); }