Ejemplo n.º 1
0
 public NuGetUIFactory(
     ICommonOperations commonOperations,
     INuGetUILogger logger,
     ISourceControlManagerProvider sourceControlManagerProvider)
 {
     ProjectContext = new NuGetUIProjectContext(
         commonOperations,
         logger,
         sourceControlManagerProvider);
 }
Ejemplo n.º 2
0
        public NuGetUIFactory(
            ICommonOperations commonOperations,
            INuGetUILogger logger,
            ISourceControlManagerProvider sourceControlManagerProvider)
        {
            ProjectContext = new NuGetUIProjectContext(
                commonOperations,
                logger,
                sourceControlManagerProvider);

            var adapterLogger = new LoggerAdapter(ProjectContext);

            ProjectContext.PackageExtractionContext = new PackageExtractionContext(
                PackageSaveMode.Defaultv2,
                PackageExtractionBehavior.XmlDocFileSaveMode,
                ClientPolicyContext.GetClientPolicy(Settings.Value, adapterLogger),
                adapterLogger);
        }
Ejemplo n.º 3
0
        public NuGetUIFactory(
            ICommonOperations commonOperations,
            INuGetUILogger logger,
            ISourceControlManagerProvider sourceControlManagerProvider)
        {
            var signedPackageVerifier = new PackageSignatureVerifier(SignatureVerificationProviderFactory.GetSignatureVerificationProviders());

            ProjectContext = new NuGetUIProjectContext(
                commonOperations,
                logger,
                sourceControlManagerProvider);

            ProjectContext.PackageExtractionContext = new PackageExtractionContext(
                PackageSaveMode.Defaultv2,
                PackageExtractionBehavior.XmlDocFileSaveMode,
                new LoggerAdapter(ProjectContext),
                signedPackageVerifier,
                SignedPackageVerifierSettings.GetDefault());
        }
        /// <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);
        }
        /// <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.Initialize();

            // ***
            // 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 stop responding.

            _dte = (DTE)GetService(typeof(SDTE));
            Debug.Assert(_dte != null);

            _dteEvents = _dte.Events.DTEEvents;
            _dteEvents.OnBeginShutdown += OnBeginShutDown;

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

            Debug.Assert(webProxy != null);

            if (SolutionManager != null)
            {
                SolutionManager.SolutionOpened += (obj, ev) =>
                {
                    _nugetSettings = new NuGetSettings();
                    LoadNuGetSettings();
                };
            }

            // 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)
            {
                if (VSVersionHelper.IsVisualStudio2013)
                {
                    // Run on a background thread in VS2013 to avoid CPS hangs. The modal loading dialog will block
                    // until this completes.
                    ThreadPool.QueueUserWorkItem(new WaitCallback((obj) =>
                                                                  PackageRestoreManager.EnableCurrentSolutionForRestore(fromActivation: false)));
                }
                else
                {
                    PackageRestoreManager.EnableCurrentSolutionForRestore(fromActivation: false);
                }
            }

            _outputConsoleLogger = new OutputConsoleLogger(this);
            _uiProjectContext    = new NuGetUIProjectContext(
                _outputConsoleLogger,
                SourceControlManagerProvider,
                CommonOperations);

            /* ****
             * // 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();
             * } */

            // 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
            // var packageRestoreManagerForOnBuildPackageRestorer = new PackageRestoreManager(SourceRepositoryProvider, Settings, SolutionManager);
            OnBuildPackageRestorer = new OnBuildPackageRestorer(SolutionManager, PackageRestoreManager, this);

            var vsSourceControlTracker = VSSourceControlTracker;

            LoadNuGetSettings();
        }