internal PackageRestoreManager(
     DTE dte,
     ISolutionManager solutionManager,
     IFileSystemProvider fileSystemProvider,
     IPackageRepositoryFactory packageRepositoryFactory,
     IVsPackageSourceProvider packageSourceProvider,
     IVsPackageManagerFactory packageManagerFactory,
     IVsPackageInstallerEvents packageInstallerEvents,
     IPackageRepository localCacheRepository,
     IVsThreadedWaitDialogFactory waitDialogFactory,
     ISettings settings)
 {
     Debug.Assert(solutionManager != null);
     _dte = dte;
     _fileSystemProvider = fileSystemProvider;
     _solutionManager = solutionManager;
     _packageRepositoryFactory = packageRepositoryFactory;
     _packageSourceProvider = packageSourceProvider;
     _waitDialogFactory = waitDialogFactory;
     _packageManagerFactory = packageManagerFactory;
     _localCacheRepository = localCacheRepository;
     _settings = settings;
     _solutionManager.ProjectAdded += OnProjectAdded;
     _solutionManager.SolutionOpened += OnSolutionOpenedOrClosed;
     _solutionManager.SolutionClosed += OnSolutionOpenedOrClosed;
     packageInstallerEvents.PackageReferenceAdded += OnPackageReferenceAdded;
 }
Exemplo n.º 2
0
        private VsPackageSourceProvider(
            ISettings settings,            
            IPackageSourceProvider packageSourceProvider,
            IVsShellInfo vsShellInfo,
            ISolutionManager solutionManager)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            if (packageSourceProvider == null)
            {
                throw new ArgumentNullException("packageSourceProvider");
            }

            if (vsShellInfo == null)
            {
                throw new ArgumentNullException("vsShellInfo");
            }

            _packageSourceProvider = packageSourceProvider;
            _solutionManager = solutionManager;
            _settings = settings;
            _vsShellInfo = vsShellInfo;

            if (null != _solutionManager)
            {
                _solutionManager.SolutionClosed += OnSolutionOpenedOrClosed;
                _solutionManager.SolutionOpened += OnSolutionOpenedOrClosed;
            }
        }
Exemplo n.º 3
0
        public RepositorySettings(ISolutionManager solutionManager, IFileSystemProvider fileSystemProvider, IVsSourceControlTracker sourceControlTracker)
        {
            if (solutionManager == null)
            {
                throw new ArgumentNullException("solutionManager");
            }

            if (fileSystemProvider == null)
            {
                throw new ArgumentNullException("fileSystemProvider");
            }

            if (sourceControlTracker == null)
            {
                throw new ArgumentNullException("sourceControlTracker");
            }

            _solutionManager = solutionManager;
            _fileSystemProvider = fileSystemProvider;

            EventHandler resetConfiguration = (sender, e) =>
            {
                // Kill our configuration cache when someone closes the solution
                _configurationPath = null;
                _fileSystem = null;
            };

            _solutionManager.SolutionClosing += resetConfiguration;
            sourceControlTracker.SolutionBoundToSourceControl += resetConfiguration;
        }
 internal GetDefaultScaffolderCmdlet(ISolutionManager solutionManager, IVsPackageManagerFactory packageManagerFactory, IScaffoldingConfigStore configStore)
     : base(solutionManager, packageManagerFactory, null)
 {
     _configStore = new Lazy<IScaffoldingConfigStore>(() => {
         return configStore ?? new XmlScaffoldingConfigStore(SolutionManager);
     });
 }
Exemplo n.º 5
0
 public VsSettings(ISolutionManager solutionManager)
     : this(solutionManager, 
     Settings.LoadDefaultSettings(GetSolutionSettingsFileSystem(solutionManager)), 
     new PhysicalFileSystemProvider())
 {
     // Review: Do we need to pass in the VsFileSystemProvider here instead of hardcoding PhysicalFileSystems?
 }
Exemplo n.º 6
0
        public DefaultHost(ISolutionManager solutionManager)
        {
            _solutionManager = solutionManager;

            _commands.Add("npm", HandleNpmCommand);
            _commands.Add("clear", HandleClearCommand);
        }
Exemplo n.º 7
0
        public VsPackageManagerFactory(ISolutionManager solutionManager,
            IPackageRepositoryFactory repositoryFactory,
            IFileSystemProvider fileSystemProvider,
            IRepositorySettings repositorySettings,
            IRecentPackageRepository recentPackagesRepository)
        {
            if (solutionManager == null) {
                throw new ArgumentNullException("solutionManager");
            }
            if (repositoryFactory == null) {
                throw new ArgumentNullException("repositoryFactory");
            }
            if (fileSystemProvider == null) {
                throw new ArgumentNullException("fileSystemProvider");
            }
            if (repositorySettings == null) {
                throw new ArgumentNullException("repositorySettings");
            }

            _fileSystemProvider = fileSystemProvider;
            _repositorySettings = repositorySettings;
            _solutionManager = solutionManager;
            _repositoryFactory = repositoryFactory;
            _recentPackageRepository = recentPackagesRepository;

            _solutionManager.SolutionClosing += (sender, e) => {
                _repositoryInfo = null;
            };
        }
Exemplo n.º 8
0
        public RecentProvider(
            Project project,
            IPackageRepository localRepository,
            ResourceDictionary resources,
            IPackageRepositoryFactory packageRepositoryFactory,
            IVsPackageManagerFactory packageManagerFactory,
            IPackageRepository recentPackagesRepository,
            IPackageSourceProvider packageSourceProvider,
            ProviderServices providerServices,
            IProgressProvider progressProvider,
            ISolutionManager solutionManager) :
            base(
                project,
                localRepository,
                resources,
                packageRepositoryFactory,
                null,
                packageManagerFactory,
                providerServices,
                progressProvider,
                solutionManager)
        {

            _recentPackagesRepository = recentPackagesRepository;
            _packageManagerFactory = packageManagerFactory;
            _packageRepositoryFactory = packageRepositoryFactory;
            _packageSourceProvider = packageSourceProvider;
        }
Exemplo n.º 9
0
        protected PackagesProviderBase(
            IPackageRepository localRepository, 
            ResourceDictionary resources, 
            ProviderServices providerServices, 
            IProgressProvider progressProvider, 
            ISolutionManager solutionManager)
        {
            if (resources == null)
            {
                throw new ArgumentNullException("resources");
            }

            if (providerServices == null)
            {
                throw new ArgumentNullException("providerServices");
            }

            if (solutionManager == null)
            {
                throw new ArgumentNullException("solutionManager");
            }

            _localRepository = localRepository;
            _providerServices = providerServices;
            _progressProvider = progressProvider;
            _solutionManager = solutionManager;
            _resources = resources;
            _outputConsole = new Lazy<IConsole>(() => providerServices.OutputConsoleProvider.CreateOutputConsole(requirePowerShellHost: false));
        }
Exemplo n.º 10
0
 internal RepositorySettings(
     ISolutionManager solutionManager, 
     IFileSystemProvider fileSystemProvider, 
     IVsSourceControlTracker sourceControlTracker) : 
     this(solutionManager, fileSystemProvider, sourceControlTracker, machineWideSettings: null)
 {
 }
Exemplo n.º 11
0
        public VsSourceControlTracker(
            ISolutionManager solutionManager, 
            IFileSystemProvider fileSystemProvider,
            IVsTrackProjectDocuments2 projectTracker,
            ISettings solutionSettings)
        {
            if (projectTracker == null)
            {
                throw new ArgumentNullException("projectTracker");
            }

            _solutionManager = solutionManager;
            _projectTracker = projectTracker;
            _fileSystemProvider = fileSystemProvider;
            _solutionSettings = solutionSettings;
            _projectDocumentListener = new TrackProjectDocumentEventListener(this);

            _solutionManager.SolutionOpened += OnSolutionOpened;
            _solutionManager.SolutionClosed += OnSolutionClosed;

            if (_solutionManager.IsSolutionOpen)
            {
                StartTracking();
            }
        }
Exemplo n.º 12
0
        public VsSettings(ISolutionManager solutionManager, ISettings defaultSettings, IFileSystemProvider fileSystemProvider)
        {
            if (solutionManager == null)
            {
                throw new ArgumentNullException("solutionManager");
            }
            if (defaultSettings == null)
            {
                throw new ArgumentNullException("defaultSettings");
            }
            if (fileSystemProvider == null)
            {
                throw new ArgumentNullException("fileSystemProvider");
            }

            _solutionManager = solutionManager;
            _defaultSettings = defaultSettings;
            _fileSystemProvider = fileSystemProvider;

            EventHandler eventHandler = (src, eventArgs) =>
            {
                _solutionSettings = null;
            };
            _solutionManager.SolutionOpened += eventHandler;
            _solutionManager.SolutionClosed += eventHandler;
        }
Exemplo n.º 13
0
        internal InstallPackageCommand(
            ISolutionManager solutionManager,
            IVsPackageManagerFactory packageManagerFactory,
            IPackageRepositoryFactory repositoryFactory,
            IVsPackageSourceProvider packageSourceProvider,
            IHttpClientEvents httpClientEvents,
            IProductUpdateService productUpdateService,
            IVsCommonOperations vsCommonOperations,
            IDeleteOnRestartManager deleteOnRestartManager,
            bool networkAvailable)
            : base(solutionManager, packageManagerFactory, httpClientEvents, vsCommonOperations, deleteOnRestartManager)
        {
            _productUpdateService = productUpdateService;
            _repositoryFactory = repositoryFactory;
            _packageSourceProvider = packageSourceProvider;
            DependencyVersion = DependencyVersion.Lowest;

            if (networkAvailable)
            {
                _isNetworkAvailable = isNetworkAvailable();
            }
            else
            {
                _isNetworkAvailable = false;
            }
        }
        public PackageRestoreManager(ISourceRepositoryProvider sourceRepositoryProvider, ISettings settings, ISolutionManager solutionManager)
        {
            if(sourceRepositoryProvider == null)
            {
                throw new ArgumentNullException("sourceRepositoryProvider");
            }

            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            if(solutionManager == null)
            {
                throw new ArgumentNullException("solutionManager");
            }

            SourceRepositoryProvider = sourceRepositoryProvider;
            Settings = settings;
            SolutionManager = solutionManager;


            SolutionManager.NuGetProjectAdded += OnNuGetProjectAdded;
            SolutionManager.SolutionOpened += OnSolutionOpenedOrClosed;
            SolutionManager.SolutionClosed += OnSolutionOpenedOrClosed;
        }
Exemplo n.º 15
0
        public GetPackageCommand(IPackageRepositoryFactory repositoryFactory,
                                IVsPackageSourceProvider packageSourceProvider,
                                ISolutionManager solutionManager,
                                IVsPackageManagerFactory packageManagerFactory,
                                IPackageRepository recentPackagesRepository,
                                IHttpClientEvents httpClientEvents,
                                IProductUpdateService productUpdateService)
            : base(solutionManager, packageManagerFactory, httpClientEvents)
        {

            if (repositoryFactory == null)
            {
                throw new ArgumentNullException("repositoryFactory");
            }
            if (packageSourceProvider == null)
            {
                throw new ArgumentNullException("packageSourceProvider");
            }
            if (recentPackagesRepository == null)
            {
                throw new ArgumentNullException("recentPackagesRepository");
            }

            _repositoryFactory = repositoryFactory;
            _packageSourceProvider = packageSourceProvider;
            _recentPackagesRepository = recentPackagesRepository;
            _productUpdateService = productUpdateService;
        }
Exemplo n.º 16
0
 public VsPackageSourceProvider(
     ISettings settings,            
     IVsShellInfo vsShellInfo,
     ISolutionManager solutionManager) :
     this(settings, new PackageSourceProvider(settings, new[] { NuGetDefaultSource }, _feedsToMigrate), vsShellInfo, solutionManager)
 {
 }
Exemplo n.º 17
0
        public VsSolution(DteSolution dteSolution, ISolutionManager solutionManager, IVsPackageManager packageManager)
        {
            _name = String.Format(
                CultureInfo.CurrentCulture,
                Strings.Label_Solution,
                dteSolution.GetName());
            _solution = solutionManager;
            _packageManager = packageManager;

            var repo = (SharedPackageRepository)packageManager.LocalRepository;
            _installedSolutionLevelPackages = new CoreInteropInstalledPackagesList(
                new PackageReferenceRepository(repo.PackageReferenceFile.FullPath, repo));

            DteSolution = dteSolution;

            // Add V2-related interop features
            AddFeature(() => packageManager.LocalRepository);
            AddFeature<IPackageManager>(() => packageManager);
            AddFeature<IPackageCacheRepository>(() => MachineCache.Default);

            // the source repository of the local repo of the solution
            AddFeature<SourceRepository>(() =>
            {
                var localRepo = new NuGet.Client.Interop.V2SourceRepository(
                    null,
                    packageManager.LocalRepository,
                    "");
                return localRepo;
            });

            // Add PowerShell feature
            AddFeature<PowerShellScriptExecutor>(() =>
                new VsPowerShellScriptExecutor(ServiceLocator.GetInstance<IScriptExecutor>()));
        }
 public VsPackageInstaller(ISourceRepositoryProvider sourceRepositoryProvider, ISettings settings, ISolutionManager solutionManager, IVsPackageInstallerServices packageServices)
 {
     _sourceRepositoryProvider = sourceRepositoryProvider;
     _settings = settings;
     _solutionManager = solutionManager;
     _projectContext = new VSAPIProjectContext();
     _packageServices = packageServices;
 }
Exemplo n.º 19
0
        public JishHost(VSConsole jsConsole, IJishInterpreter jish)
        {
            this.jsConsole = jsConsole;
              this.jish = jish;
              solutionManager = ((IComponentModel) Package.GetGlobalService(typeof (SComponentModel))).GetService<ISolutionManager>();

              IsCommandEnabled = true;
        }
 public VSPackageRestoreManager(ISourceRepositoryProvider sourceRepositoryProvider, ISettings settings, ISolutionManager solutionManager)
     : base(sourceRepositoryProvider, settings, solutionManager)
 {
     SolutionManager = solutionManager;
     SolutionManager.NuGetProjectAdded += OnNuGetProjectAdded;
     SolutionManager.SolutionOpened += OnSolutionOpenedOrClosed;
     SolutionManager.SolutionClosed += OnSolutionOpenedOrClosed;
 }
 public UninstallPackageCommand(ISolutionManager solutionManager,
                                IVsPackageManagerFactory packageManagerFactory,
                                IHttpClientEvents httpClientEvents,
                                IVsCommonOperations vsCommonOperations,
                                IDeleteOnRestartManager deleteOnRestartManager)
     : base(solutionManager, packageManagerFactory, httpClientEvents, vsCommonOperations, deleteOnRestartManager)
 {
 }
 internal GetScaffolderCmdlet(ISolutionManager solutionManager, IVsPackageManagerFactory vsPackageManagerFactory, IScaffolderLocator scaffolderLocator)
     : base(solutionManager, vsPackageManagerFactory, null)
 {
     // Can't read the value of CommandInvoker until *after* the constructor finishes, hence lazy
     _scaffolderLocator = new Lazy<IScaffolderLocator>(
         () => scaffolderLocator ?? new Ps1ScaffolderLocator(CommandInvoker, PackageManager, null, new DefaultFileSystem(), new XmlScaffoldingConfigStore(SolutionManager))
     );
 }
Exemplo n.º 23
0
 public UpdatePackageCommand(ISolutionManager solutionManager, 
     IVsPackageManagerFactory packageManagerFactory,
     IHttpClientEvents httpClientEvents,
     IProductUpdateService productUpdateService)
     : base(solutionManager, packageManagerFactory, httpClientEvents)
 {
     _productUpdateService = productUpdateService;
 }
Exemplo n.º 24
0
        public VsPackageManager(ISolutionManager solutionManager, IPackageRepository sourceRepository, IFileSystem fileSystem, ISharedPackageRepository sharedRepository, IPackageRepository recentPackagesRepository)
            : base(sourceRepository, new DefaultPackagePathResolver(fileSystem), fileSystem, sharedRepository)
        {
            _solutionManager = solutionManager;
            _sharedRepository = sharedRepository;
            _recentPackagesRepository = recentPackagesRepository;

            _projects = new Dictionary<string, IProjectManager>(StringComparer.OrdinalIgnoreCase);
        }
Exemplo n.º 25
0
        public FindPackageCommand(IPackageRepositoryFactory repositoryFactory,
                          IVsPackageSourceProvider packageSourceProvider,
                          ISolutionManager solutionManager,
                          IVsPackageManagerFactory packageManagerFactory,
                          IHttpClientEvents httpClientEvents)
            : base(repositoryFactory, packageSourceProvider, solutionManager, packageManagerFactory, httpClientEvents, null)
        {

        }
Exemplo n.º 26
0
        private PackageManagerWindow(Project project,
                                    DTE dte,
                                    IVsPackageManagerFactory packageManagerFactory,
                                    IPackageRepositoryFactory repositoryFactory,
                                    IPackageSourceProvider packageSourceProvider,
                                    IRecentPackageRepository recentPackagesRepository,
                                    IHttpClientEvents httpClientEvents,
                                    IProductUpdateService productUpdateService,
                                    IPackageRestoreManager packageRestoreManager,
                                    ISolutionManager solutionManager,
                                    IOptionsPageActivator optionPageActivator)
            : base(F1Keyword)
        {

            InitializeComponent();

#if !VS10
            // set unique search guid for VS11
            explorer.SearchCategory = new Guid("{85566D5F-E585-411F-B299-5BF006E9F11E}");
#endif

            _httpClientEvents = httpClientEvents;
            if (_httpClientEvents != null)
            {
                _httpClientEvents.SendingRequest += OnSendingRequest;
            }

            _productUpdateService = productUpdateService;
            _optionsPageActivator = optionPageActivator;
            _activeProject = project;

            // replace the ConsoleOutputProvider with SmartOutputConsoleProvider so that we can clear 
            // the console the first time an entry is written to it
            var providerServices = new ProviderServices();
            _smartOutputConsoleProvider = new SmartOutputConsoleProvider(providerServices.OutputConsoleProvider);
            providerServices.OutputConsoleProvider = _smartOutputConsoleProvider;
            _providerSettings = providerServices.ProviderSettings;

            AddUpdateBar(productUpdateService);
            AddRestoreBar(packageRestoreManager);
            InsertDisclaimerElement();
            AdjustSortComboBoxWidth();
            PreparePrereleaseComboBox();

            SetupProviders(
                project,
                dte,
                packageManagerFactory,
                repositoryFactory,
                packageSourceProvider,
                providerServices,
                recentPackagesRepository,
                httpClientEvents,
                solutionManager,
                packageRestoreManager);
        }
Exemplo n.º 27
0
 public VsPackageManagerFactory(ISolutionManager solutionManager,
                                IPackageRepositoryFactory repositoryFactory,
                                IVsPackageSourceProvider packageSourceProvider,
                                IFileSystemProvider fileSystemProvider,
                                IRepositorySettings repositorySettings,
                                IRecentPackageRepository recentPackagesRepository,
                                VsPackageInstallerEvents packageEvents) :
     this(solutionManager, repositoryFactory, packageSourceProvider, fileSystemProvider, repositorySettings, recentPackagesRepository, packageEvents, MachineCache.Default)
 {
 }
Exemplo n.º 28
0
 public IDisposable SaveSolutionExplorerNodeStates(ISolutionManager solutionManager)
 {
     IDictionary<string, ISet<VsHierarchyItem>> expandedNodes = VsHierarchyHelper.GetAllExpandedNodes(solutionManager);
     return new DisposableAction(() =>
         {
             VsHierarchyHelper.CollapseAllNodes(solutionManager, expandedNodes);
             expandedNodes.Clear();
             expandedNodes = null;
         });
 }
 protected ProcessPackageBaseCommand(
     ISolutionManager solutionManager, 
     IVsPackageManagerFactory packageManagerFactory, 
     IHttpClientEvents httpClientEvents,
     IVsCommonOperations vsCommonOperations)
     : base(solutionManager, packageManagerFactory, httpClientEvents)
 {
     Debug.Assert(vsCommonOperations != null);
     _vsCommonOperations = vsCommonOperations;
 }
Exemplo n.º 30
0
 public PreinstalledPackageInstaller(
     IVsWebsiteHandler websiteHandler,
     IVsPackageInstallerServices packageServices,
     IVsCommonOperations vsCommonOperations,
     ISolutionManager solutionManager)
 {
     _websiteHandler = websiteHandler;
     _packageServices = packageServices;
     _vsCommonOperations = vsCommonOperations;
     _solutionManager = solutionManager;
 }
Exemplo n.º 31
0
        public PackagesErrorBar(ISolutionManager solutionManager)
        {
            InitializeComponent();

            _solutionManager = solutionManager;

            // Start a task to check for all the project's packages file and accordingly update error bar.
            // this would also be initlize VSSolutionManager first time, if it hasn't been initialized yet.
            Task.Run(UpdateErrorBarAsync);

            ErrorMessage.SetResourceReference(TextBlock.ForegroundProperty, VsBrushes.InfoTextKey);
            ErrorBar.SetResourceReference(Border.BackgroundProperty, VsBrushes.InfoBackgroundKey);
            ErrorBar.SetResourceReference(Border.BorderBrushProperty, VsBrushes.ActiveBorderKey);
        }
Exemplo n.º 32
0
        private static IMSBuildNuGetProjectSystem GetMSBuildNuGetProjectSystem(ISolutionManager solutionManager, EnvDTEProject envDTEProject)
        {
            var nuGetProject = solutionManager.GetNuGetProject(envDTEProject.Name);

            if (nuGetProject != null)
            {
                var msBuildNuGetProject = nuGetProject as MSBuildNuGetProject;
                if (msBuildNuGetProject != null)
                {
                    return(msBuildNuGetProject.MSBuildNuGetProjectSystem);
                }
            }
            return(null);
        }
Exemplo n.º 33
0
 public InstallPackageCommand(
     ISolutionManager solutionManager,
     IVsPackageManagerFactory packageManagerFactory,
     IPackageRepositoryFactory repositoryFactory,
     IVsPackageSourceProvider packageSourceProvider,
     IHttpClientEvents httpClientEvents,
     IProductUpdateService productUpdateService,
     IVsCommonOperations vsCommonOperations)
     : base(solutionManager, packageManagerFactory, httpClientEvents, vsCommonOperations)
 {
     _productUpdateService  = productUpdateService;
     _repositoryFactory     = repositoryFactory;
     _packageSourceProvider = packageSourceProvider;
 }
Exemplo n.º 34
0
 public PreinstalledPackageInstaller(
     IVsPackageInstallerServices packageServices,
     ISolutionManager solutionManager,
     Configuration.ISettings settings,
     ISourceRepositoryProvider sourceProvider,
     VsPackageInstaller installer)
 {
     //_websiteHandler = websiteHandler;
     _packageServices = packageServices;
     //_vsCommonOperations = vsCommonOperations;
     _solutionManager = solutionManager;
     _sourceProvider  = sourceProvider;
     _installer       = installer;
 }
 public PackageActionBaseCommand(
     IVsPackageSourceProvider packageSourceProvider,
     IPackageRepositoryFactory packageRepositoryFactory,
     SVsServiceProvider svcServiceProvider,
     IVsPackageManagerFactory packageManagerFactory,
     ISolutionManager solutionManager,
     IHttpClientEvents clientEvents,
     PackageActionType actionType)
     : base(packageSourceProvider, packageRepositoryFactory, svcServiceProvider, packageManagerFactory, solutionManager, clientEvents)
 {
     _actionType             = actionType;
     _vsCommonOperations     = ServiceLocator.GetInstance <IVsCommonOperations>();
     _deleteOnRestartManager = ServiceLocator.GetInstance <IDeleteOnRestartManager>();
 }
Exemplo n.º 36
0
 public StandaloneUIContext(
     string settingsFile,
     ISourceRepositoryProvider sourceProvider,
     ISolutionManager solutionManager,
     NuGetPackageManager packageManager,
     UIActionEngine uiActionEngine,
     IPackageRestoreManager packageRestoreManager,
     IOptionsPageActivator optionsPageActivator,
     IEnumerable <NuGet.ProjectManagement.NuGetProject> projects) :
     base(sourceProvider, solutionManager, packageManager, uiActionEngine, packageRestoreManager, optionsPageActivator, projects)
 {
     _settingsFile = settingsFile;
     LoadSettings();
 }
Exemplo n.º 37
0
        /// <summary>
        /// Restore many projects without writing the lock file
        /// SourceRepositories(sources) is only used for the CachingSourceProvider, the project-specific sources will still be resolved in RestoreRunner.
        /// </summary>
        internal static async Task <IEnumerable <RestoreResultPair> > PreviewRestoreProjectsAsync(
            ISolutionManager solutionManager,
            IEnumerable <BuildIntegratedNuGetProject> projects,
            IEnumerable <PackageSpec> updatedNugetPackageSpecs,
            DependencyGraphCacheContext context,
            RestoreCommandProvidersCache providerCache,
            Action <SourceCacheContext> cacheContextModifier,
            IEnumerable <SourceRepository> sources,
            Guid parentId,
            ILogger log,
            CancellationToken token)
        {
            token.ThrowIfCancellationRequested();

            // Add the new spec to the dg file and fill in the rest.
            var dgFile = await GetSolutionRestoreSpec(solutionManager, context);

            dgFile = dgFile.WithoutRestores()
                     .WithPackageSpecs(updatedNugetPackageSpecs);

            foreach (var project in projects)
            {
                dgFile.AddRestore(project.MSBuildProjectPath);
            }

            using (var sourceCacheContext = new SourceCacheContext())
            {
                // Update cache context
                cacheContextModifier(sourceCacheContext);

                // Settings passed here will be used to populate the restore requests.
                var restoreContext = GetRestoreContext(
                    context,
                    providerCache,
                    sourceCacheContext,
                    sources,
                    dgFile,
                    parentId,
                    forceRestore: true,
                    isRestoreOriginalAction: false,
                    restoreForceEvaluate: true,
                    additionalMessasges: null);

                var requests = await RestoreRunner.GetRequests(restoreContext);

                var results = await RestoreRunner.RunWithoutCommit(requests, restoreContext);

                return(results);
            }
        }
        public CodeGenerator(ITextTemplatingEngineHost host, ITextTemplatingSessionHost textTemplatingSessionHost, ITextTemplating textTemplating, ISolutionManager solutionManager, string rosMessagesProjectName, string rosMessageTypeAttributeName, string rosMessageTypeAttributeNamespace)
        {
            if (null == host)
            {
                throw new ArgumentNullException(nameof(host));
            }

            if (null == textTemplatingSessionHost)
            {
                throw new ArgumentNullException(nameof(textTemplatingSessionHost));
            }

            if (null == textTemplating)
            {
                throw new ArgumentNullException(nameof(textTemplating));
            }

            if (null == solutionManager)
            {
                throw new ArgumentNullException(nameof(solutionManager));
            }

            if (string.IsNullOrWhiteSpace(rosMessagesProjectName))
            {
                throw new ArgumentException("Parameter cannot be empty!", nameof(rosMessagesProjectName));
            }

            if (string.IsNullOrWhiteSpace(rosMessageTypeAttributeName))
            {
                throw new ArgumentException("Parameter cannot be empty!", nameof(rosMessageTypeAttributeName));
            }

            if (string.IsNullOrWhiteSpace(rosMessageTypeAttributeNamespace))
            {
                throw new ArgumentException("Parameter cannot be empty!", nameof(rosMessageTypeAttributeNamespace));
            }

            _textTemplatingEngineHost         = host;
            _textTemplating                   = textTemplating;
            _textTemplatingSessionHost        = textTemplatingSessionHost;
            _solutionManager                  = solutionManager;
            _rosMessageTypeAttributeName      = rosMessageTypeAttributeName;
            _rosMessageTypeAttributeNamespace = rosMessageTypeAttributeNamespace;

            _defaultNamespace = rosMessagesProjectName;
            _rosMessageCodeGenerationTemplatePath    = _textTemplatingEngineHost.ResolvePath(ROS_MESSAGE_CODE_GENERATION_TEMPLATE_RELATIVE_PATH);
            _rosMessageCodeGenerationTemplateContent = ReadAllTextFromFile(_rosMessageCodeGenerationTemplatePath);
            _customTimeDataTemplatePath = _textTemplatingEngineHost.ResolvePath(CUSTOM_TIME_DATA_TEMPLATE_RELATIVE_PATH);
            _solutionManager.Initialize();
        }
Exemplo n.º 39
0
 public UpdatePackageCommand(ISolutionManager solutionManager,
                             IVsPackageManagerFactory packageManagerFactory,
                             IPackageRepositoryFactory repositoryFactory,
                             IVsPackageSourceProvider packageSourceProvider,
                             IHttpClientEvents httpClientEvents,
                             IProductUpdateService productUpdateService,
                             IVsCommonOperations vsCommonOperations,
                             IDeleteOnRestartManager deleteOnRestartManager)
     : base(solutionManager, packageManagerFactory, httpClientEvents, vsCommonOperations, deleteOnRestartManager)
 {
     _repositoryFactory     = repositoryFactory;
     _packageSourceProvider = packageSourceProvider;
     _productUpdateService  = productUpdateService;
 }
Exemplo n.º 40
0
        private static IMSBuildProjectSystem GetMSBuildNuGetProjectSystem(ISolutionManager solutionManager, IVsProjectAdapter vsProjectAdapter)
        {
            var nuGetProject = solutionManager.GetNuGetProject(vsProjectAdapter.ProjectName);

            if (nuGetProject != null)
            {
                var msBuildNuGetProject = nuGetProject as MSBuildNuGetProject;
                if (msBuildNuGetProject != null)
                {
                    return(msBuildNuGetProject.ProjectSystem);
                }
            }
            return(null);
        }
        /// <summary>
        /// Restore a solution and cache the dg spec to context.
        /// </summary>
        public static async Task <IReadOnlyList <RestoreSummary> > RestoreAsync(
            ISolutionManager solutionManager,
            DependencyGraphSpec dgSpec,
            DependencyGraphCacheContext context,
            RestoreCommandProvidersCache providerCache,
            Action <SourceCacheContext> cacheContextModifier,
            IEnumerable <SourceRepository> sources,
            Guid parentId,
            bool forceRestore,
            bool isRestoreOriginalAction,
            IReadOnlyList <IAssetsLogMessage> additionalMessages,
            ILogger log,
            CancellationToken token)
        {
            // TODO: This will flow from UI once we enable UI option to trigger reevaluation
            var restoreForceEvaluate = false;

            // Check if there are actual projects to restore before running.
            if (dgSpec.Restore.Count > 0)
            {
                using (var sourceCacheContext = new SourceCacheContext())
                {
                    // Update cache context
                    cacheContextModifier(sourceCacheContext);

                    var restoreContext = GetRestoreContext(
                        context,
                        providerCache,
                        sourceCacheContext,
                        sources,
                        dgSpec,
                        parentId,
                        forceRestore,
                        isRestoreOriginalAction,
                        restoreForceEvaluate,
                        additionalMessages);

                    var restoreSummaries = await RestoreRunner.RunAsync(restoreContext, token);

                    RestoreSummary.Log(log, restoreSummaries);

                    await PersistDGSpec(dgSpec);

                    return(restoreSummaries);
                }
            }

            return(new List <RestoreSummary>());
        }
Exemplo n.º 42
0
 public VsTemplateWizard(
     IVsPackageInstaller installer,
     IVsWebsiteHandler websiteHandler,
     IVsPackageInstallerServices packageServices,
     IOutputConsoleProvider consoleProvider,
     IVsCommonOperations vsCommonOperations,
     ISolutionManager solutionManager)
 {
     _installer          = installer;
     _websiteHandler     = websiteHandler;
     _packageServices    = packageServices;
     _consoleProvider    = consoleProvider;
     _vsCommonOperations = vsCommonOperations;
     _solutionManager    = solutionManager;
 }
Exemplo n.º 43
0
 public VisualStudioUIContext(
     NuGetPackage package,
     ISourceRepositoryProvider sourceProvider,
     ISolutionManager solutionManager,
     NuGetPackageManager packageManager,
     UIActionEngine uiActionEngine,
     IPackageRestoreManager packageRestoreManager,
     IOptionsPageActivator optionsPageActivator,
     IEnumerable <NuGetProject> projects,
     IEnumerable <IVsPackageManagerProvider> packageManagerProviders)
     :
     base(sourceProvider, solutionManager, packageManager, uiActionEngine, packageRestoreManager, optionsPageActivator, projects, packageManagerProviders)
 {
     _package = package;
 }
        public static string GetPackagesFolderPath(ISolutionManager solutionManager, ISettings settings)
        {
            if (solutionManager == null)
            {
                throw new ArgumentNullException("solutionManager");
            }

            // If the solution directory is unavailable then throw an exception
            if (solutionManager.SolutionDirectory == null)
            {
                throw new InvalidOperationException(Strings.SolutionDirectoryNotAvailable);
            }

            return(GetPackagesFolderPath(solutionManager.SolutionDirectory, settings));
        }
Exemplo n.º 45
0
 public VsPackageInstaller(
     ISourceRepositoryProvider sourceRepositoryProvider,
     Configuration.ISettings settings,
     ISolutionManager solutionManager,
     IVsPackageInstallerServices packageServices,
     IDeleteOnRestartManager deleteOnRestartManager)
 {
     _sourceRepositoryProvider = sourceRepositoryProvider;
     _settings               = settings;
     _solutionManager        = solutionManager;
     _projectContext         = new VSAPIProjectContext();
     _packageServices        = packageServices;
     _deleteOnRestartManager = deleteOnRestartManager;
     PumpingJTF              = new PumpingJTF(ThreadHelper.JoinableTaskContext);
 }
Exemplo n.º 46
0
        public static NuGetProject GetNuGetProject(EnvDTE.Project project, ISolutionManager solutionManager)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            Debug.Assert(project != null);
            Debug.Assert(solutionManager != null);

            var nuGetProject = solutionManager.GetNuGetProject(project.Name);

            if (nuGetProject == null)
            {
                nuGetProject = solutionManager.GetNuGetProject(project.UniqueName);
            }
            return(nuGetProject);
        }
 public static void EnsureCheckedOutIfExists(this ISolutionManager solutionManager, string fullPath)
 {
     if (File.Exists(fullPath))
     {
         var project = solutionManager.GetProjects().FirstOrDefault();
         if ((project != null) && (project.DTE != null) && (project.DTE.SourceControl != null))
         {
             var sourceControl = project.DTE.SourceControl;
             if (sourceControl.IsItemUnderSCC(fullPath) && !sourceControl.IsItemCheckedOut(fullPath))
             {
                 sourceControl.CheckOutItem(fullPath);
             }
         }
     }
 }
Exemplo n.º 48
0
        public VsSourceControlTracker(
            [Import(typeof(SVsServiceProvider))]
            IServiceProvider serviceProvider,
            ISolutionManager solutionManager,
            ISourceControlManagerProvider sourceControlManagerProvider,
            Configuration.ISettings vsSettings)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            if (solutionManager == null)
            {
                throw new ArgumentNullException(nameof(solutionManager));
            }

            if (sourceControlManagerProvider == null)
            {
                throw new ArgumentNullException(nameof(sourceControlManagerProvider));
            }

            if (vsSettings == null)
            {
                throw new ArgumentNullException(nameof(vsSettings));
            }

            _solutionManager = solutionManager;
            _sourceControlManagerProvider = sourceControlManagerProvider;
            _vsSettings = vsSettings;

            _projectTracker = new AsyncLazy <IVsTrackProjectDocuments2>(async() =>
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                return(serviceProvider.GetService <SVsTrackProjectDocuments, IVsTrackProjectDocuments2>());
            },
                                                                        ThreadHelper.JoinableTaskFactory);

            _projectDocumentListener = new TrackProjectDocumentEventListener(this);

            _solutionManager.SolutionOpened += OnSolutionOpened;
            _solutionManager.SolutionClosed += OnSolutionClosed;

            if (_solutionManager.IsSolutionOpen)
            {
                StartTracking();
            }
        }
Exemplo n.º 49
0
        protected ViewModelBase(IHistoryManager history,
                                DatabaseTableSolutionItem solutionItem,
                                ISolutionItemNameRegistry solutionItemName,
                                ISolutionManager solutionManager,
                                ISolutionTasksService solutionTasksService,
                                IEventAggregator eventAggregator,
                                IQueryGenerator queryGenerator,
                                IDatabaseTableDataProvider databaseTableDataProvider,
                                IMessageBoxService messageBoxService,
                                ITaskRunner taskRunner,
                                IParameterFactory parameterFactory,
                                ITableDefinitionProvider tableDefinitionProvider,
                                IItemFromListProvider itemFromListProvider,
                                ISolutionItemIconRegistry iconRegistry,
                                ISessionService sessionService,
                                IDatabaseTableCommandService commandService)
        {
            this.solutionItemName          = solutionItemName;
            this.solutionManager           = solutionManager;
            this.solutionTasksService      = solutionTasksService;
            this.queryGenerator            = queryGenerator;
            this.databaseTableDataProvider = databaseTableDataProvider;
            this.messageBoxService         = messageBoxService;
            this.taskRunner           = taskRunner;
            this.parameterFactory     = parameterFactory;
            this.itemFromListProvider = itemFromListProvider;
            this.sessionService       = sessionService;
            this.commandService       = commandService;
            this.solutionItem         = solutionItem;
            History = history;

            undoCommand            = new DelegateCommand(History.Undo, CanUndo);
            redoCommand            = new DelegateCommand(History.Redo, CanRedo);
            Save                   = new DelegateCommand(SaveSolutionItem);
            title                  = solutionItemName.GetName(solutionItem);
            Icon                   = iconRegistry.GetIcon(solutionItem);
            nameGeneratorParameter = parameterFactory.Factory("Parameter");

            History.PropertyChanged += (_, _) =>
            {
                undoCommand.RaiseCanExecuteChanged();
                redoCommand.RaiseCanExecuteChanged();
                RaisePropertyChanged(nameof(IsModified));
            };

            tableDefinition        = tableDefinitionProvider.GetDefinition(solutionItem.DefinitionId) !;
            nameGeneratorParameter = parameterFactory.Factory(tableDefinition.Picker);
        }
 public VisualStudioUIContextFactory([Import] ISourceRepositoryProvider repositoryProvider,
                                     [Import] ISolutionManager solutionManager,
                                     [Import] ISettings settings,
                                     [Import] IPackageRestoreManager packageRestoreManager,
                                     [Import] IOptionsPageActivator optionsPage,
                                     [Import] IDeleteOnRestartManager deleteOnRestartManager,
                                     [ImportMany] IEnumerable <Lazy <IVsPackageManagerProvider, IOrderable> > packageManagerProviders)
 {
     _repositoryProvider      = repositoryProvider;
     _solutionManager         = solutionManager;
     _restoreManager          = packageRestoreManager;
     _optionsPage             = optionsPage;
     _settings                = settings;
     _deleteOnRestartManager  = deleteOnRestartManager;
     _packageManagerProviders = PackageManagerProviderUtility.Sort(packageManagerProviders, MaxPackageManager);
 }
Exemplo n.º 51
0
        public Task CollapseAllNodes(ISolutionManager solutionManager)
        {
            if (solutionManager == null)
            {
                throw new ArgumentNullException(nameof(solutionManager));
            }

            return(NuGetUIThreadHelper.JoinableTaskFactory.Run(async delegate
            {
                await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                await VsHierarchyUtility.CollapseAllNodesAsync(solutionManager, _expandedNodes);

                return Task.CompletedTask;
            }));
        }
Exemplo n.º 52
0
        public VSPackageRestoreManager(
            ISourceRepositoryProvider sourceRepositoryProvider,
            Configuration.ISettings settings,
            ISolutionManager solutionManager)
            : base(sourceRepositoryProvider, settings, solutionManager)
        {
            if (solutionManager == null)
            {
                throw new ArgumentNullException(nameof(solutionManager));
            }

            SolutionManager = solutionManager;
            SolutionManager.NuGetProjectAdded += OnNuGetProjectAdded;
            SolutionManager.SolutionOpened    += OnSolutionOpenedOrClosed;
            SolutionManager.SolutionClosed    += OnSolutionOpenedOrClosed;
        }
Exemplo n.º 53
0
        public static void AddBindingRedirects(ISolutionManager solutionManager, Project project)
        {
            // Create a new app domain so we can load the assemblies without locking them in this app domain
            AppDomain domain = AppDomain.CreateDomain("assembliesDomain");

            try {
                // Keep track of visited projects
                if (project.SupportsBindingRedirects())
                {
                    AddBindingRedirects(solutionManager, project, domain);
                }
            }
            finally {
                AppDomain.Unload(domain);
            }
        }
Exemplo n.º 54
0
 public static void CollapseAllNodes(ISolutionManager solutionManager, IDictionary <string, ISet <VsHierarchyItem> > ignoreNodes)
 {
     // this operation needs to execute on UI thread
     ThreadHelper.Generic.Invoke(() =>
     {
         foreach (Project project in solutionManager.GetProjects())
         {
             ISet <VsHierarchyItem> expandedNodes;
             if (ignoreNodes.TryGetValue(project.UniqueName, out expandedNodes) &&
                 expandedNodes != null)
             {
                 CollapseProjectHierarchyItems(project, expandedNodes);
             }
         }
     });
 }
Exemplo n.º 55
0
 /// <summary>
 /// Preprocess to get resourceRepositoryProvider and solutionManager from packageManagementContext.
 /// </summary>
 protected virtual void Preprocess()
 {
     _packageManagementContext = (PackageManagementContext)GetPropertyValueFromHost(PackageManagementContextKey);
     if (_packageManagementContext != null)
     {
         _resourceRepositoryProvider = _packageManagementContext.SourceRepositoryProvider;
         _solutionManager            = _packageManagementContext.VsSolutionManager;
         _settings         = _packageManagementContext.Settings;
         _commonOperations = _packageManagementContext.CommonOperations;
         if (_commonOperations != null)
         {
             ExecutionContext = new IDEExecutionContext(_commonOperations);
         }
     }
     _dte = (DTE)GetPropertyValueFromHost(DTEKey);
 }
Exemplo n.º 56
0
        public Task SaveSolutionExplorerNodeStates(ISolutionManager solutionManager)
        {
            if (solutionManager == null)
            {
                throw new ArgumentNullException(nameof(solutionManager));
            }

            return(ThreadHelper.JoinableTaskFactory.Run(async delegate
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                _expandedNodes = await VsHierarchyUtility.GetAllExpandedNodesAsync(solutionManager);

                return Task.FromResult(0);
            }));
        }
        /// <summary>
        ///  Return the numnber of calls sites for a
        /// </summary>
        /// <param name="methodDescriptor"></param>
        /// <param name="projectName"></param>
        /// <returns></returns>
        public static async Task <int> GetInvocationCountAsync(ISolutionManager solutionManager, MethodDescriptor methodDescriptor)
        {
            var totalStopWatch = Stopwatch.StartNew();
            var stopWatch      = Stopwatch.StartNew();

            var entityWithPropagator = await solutionManager.GetMethodEntityAsync(methodDescriptor);

            Meausure("GetMethodEntityProp", stopWatch);

            var result = await entityWithPropagator.GetInvocationCountAsync();

            Meausure("entProp.GetInvocationCountAsync", stopWatch);

            Meausure("Total GetInvocationCountAsync", totalStopWatch);
            return(result);
        }
Exemplo n.º 58
0
        /// <summary>
        /// Restore without writing the lock file
        /// </summary>
        internal static async Task <RestoreResultPair> PreviewRestoreAsync(
            ISolutionManager solutionManager,
            BuildIntegratedNuGetProject project,
            PackageSpec packageSpec,
            DependencyGraphCacheContext context,
            RestoreCommandProvidersCache providerCache,
            Action <SourceCacheContext> cacheContextModifier,
            IEnumerable <SourceRepository> sources,
            Guid parentId,
            ILogger log,
            CancellationToken token)
        {
            // Restoring packages
            var logger = context.Logger;

            // Add the new spec to the dg file and fill in the rest.
            var dgFile = await GetSolutionRestoreSpec(solutionManager, context);

            dgFile = dgFile.WithoutRestores()
                     .WithReplacedSpec(packageSpec);

            dgFile.AddRestore(project.MSBuildProjectPath);

            using (var sourceCacheContext = new SourceCacheContext())
            {
                // Update cache context
                cacheContextModifier(sourceCacheContext);

                // Settings passed here will be used to populate the restore requests.
                var restoreContext = GetRestoreContext(
                    context,
                    providerCache,
                    sourceCacheContext,
                    sources,
                    dgFile,
                    parentId,
                    forceRestore: true,
                    isRestoreOriginalAction: false,
                    restoreForceEvaluate: true);

                var requests = await RestoreRunner.GetRequests(restoreContext);

                var results = await RestoreRunner.RunWithoutCommit(requests, restoreContext);

                return(results.Single());
            }
        }
Exemplo n.º 59
0
 public OnlineProvider(
     Project project,
     IPackageRepository localRepository,
     ResourceDictionary resources,
     IPackageRepositoryFactory packageRepositoryFactory,
     IPackageSourceProvider packageSourceProvider,
     IVsPackageManagerFactory packageManagerFactory,
     ProviderServices providerServices,
     IProgressProvider progressProvider,
     ISolutionManager solutionManager) :
     base(localRepository, resources, providerServices, progressProvider, solutionManager)
 {
     _packageRepositoryFactory = packageRepositoryFactory;
     _packageSourceProvider    = packageSourceProvider;
     _packageManagerFactory    = packageManagerFactory;
     _project = project;
 }
Exemplo n.º 60
0
        private static void AddBindingRedirects(ISolutionManager solutionManager, Project project, AppDomain domain, HashSet <string> projects, IDictionary <string, HashSet <string> > projectAssembliesCache)
        {
            if (projects.Contains(project.UniqueName))
            {
                return;
            }

            AddBindingRedirects(project, domain, projectAssembliesCache);

            // Add binding redirects to all projects that are referencing this one
            foreach (Project dependentProject in solutionManager.GetDependentProjects(project))
            {
                AddBindingRedirects(solutionManager, dependentProject, domain, projects, projectAssembliesCache);
            }

            projects.Add(project.UniqueName);
        }