Exemple #1
0
        /// <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();

            // 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);

            // set default credential provider for the HttpClient
            var webProxy = (IVsWebProxy)GetService(typeof(SVsWebProxy));

            Debug.Assert(webProxy != null);

            var settings = Settings.LoadDefaultSettings(_solutionManager == null ? null : _solutionManager.SolutionFileSystem);
            var packageSourceProvider = new PackageSourceProvider(settings);

            HttpClient.DefaultCredentialProvider = new SettingsCredentialProvider(new VSRequestCredentialProvider(webProxy), packageSourceProvider);

            // when NuGet loads, if the current solution has package
            // restore mode enabled, we make sure every thing is set up correctly.
            // For example, projects which were added outside of VS need to have
            // the <Import> element added.
            if (PackageRestoreManager.IsCurrentSolutionEnabledForRestore)
            {
                _packageRestoreManager.EnableCurrentSolutionForRestore(fromActivation: false);
            }
        }
Exemple #2
0
 private void EnablePackagesRestore(object sender, EventArgs args)
 {
     if (VsVersionHelper.IsVisualStudio2013)
     {
         // This method is called by the UI thread when the user clicks the menu item. To avoid
         // hangs on CPS project systems this needs to be done on a background thread.
         ThreadPool.QueueUserWorkItem(new WaitCallback((obj) =>
                                                       _packageRestoreManager.EnableCurrentSolutionForRestore(fromActivation: true)));
     }
     else
     {
         _packageRestoreManager.EnableCurrentSolutionForRestore(fromActivation: true);
     }
 }
Exemple #3
0
        /// <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();

            // get the UI context cookie for the debugging mode
            _vsMonitorSelection = (IVsMonitorSelection)GetService(typeof(IVsMonitorSelection));
            // get debugging context cookie
            Guid debuggingContextGuid = VSConstants.UICONTEXT_Debugging;
            _vsMonitorSelection.GetCmdUIContextCookie(ref debuggingContextGuid, out _debuggingContextCookie);

            // get the solution building cookie
            Guid solutionBuildingContextGuid = VSConstants.UICONTEXT_SolutionBuilding;
            _vsMonitorSelection.GetCmdUIContextCookie(ref solutionBuildingContextGuid, out _solutionBuildingContextCookie);

            _dte = ServiceLocator.GetInstance<DTE>();
            _consoleStatus = ServiceLocator.GetInstance<IConsoleStatus>();
            _packageRestoreManager = ServiceLocator.GetInstance<IPackageRestoreManager>();
            Debug.Assert(_packageRestoreManager != null);

            // Add our command handlers for menu (commands must exist in the .vsct file)
            AddMenuCommandHandlers();

            // when NuGet loads, if the current solution has package 
            // restore mode enabled, we make sure every thing is set up correctly.
            // For example, projects which were added outside of VS need to have
            // the <Import> element added.
            if (_packageRestoreManager.IsCurrentSolutionEnabledForRestore)
            {
                _packageRestoreManager.EnableCurrentSolutionForRestore(quietMode: true);
            }
        }
Exemple #4
0
 private void EnablePackagesRestore(object sender, EventArgs args)
 {
     _packageRestoreManager.EnableCurrentSolutionForRestore(fromActivation: true);
 }