Esempio n. 1
0
 public VsPackageSourceProvider(
     ISettings settings,
     IVsShellInfo vsShellInfo,
     ISolutionManager solutionManager) :
     this(settings, new PackageSourceProvider(settings, new[] { NuGetV3Source, NuGetDefaultSource }, _feedsToMigrate), vsShellInfo, solutionManager)
 {
 }
Esempio 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;
            _packageSources = new List <PackageSource>();

            if (null != _solutionManager)
            {
                _solutionManager.SolutionClosed += OnSolutionOpenedOrClosed;
                _solutionManager.SolutionOpened += OnSolutionOpenedOrClosed;
            }
        }
Esempio n. 3
0
 internal VsPackageSourceProvider(
     ISettings settings,
     IPackageSourceProvider packageSourceProvider,
     IVsShellInfo vsShellInfo)
     : this(settings, packageSourceProvider, vsShellInfo, null)
 {
 }
Esempio n. 4
0
 public VsPackageSourceProvider(
     ISettings settings,            
     IVsShellInfo vsShellInfo,
     ISolutionManager solutionManager) :
     this(settings, new PackageSourceProvider(settings, new[] { NuGetDefaultSource }, _feedsToMigrate), vsShellInfo, solutionManager)
 {
 }
Esempio n. 5
0
 internal VsPackageSourceProvider(
     ISettings settings,
     IPackageSourceProvider packageSourceProvider,
     IVsShellInfo vsShellInfo)
     :this(settings, packageSourceProvider, vsShellInfo, null)
 {
 }
Esempio n. 6
0
        private static PackageSource DeserializeActivePackageSource(
            ISettings settings,
            IVsShellInfo vsShellInfo)
        {
            var settingValues = settings.GetValues(ActivePackageSourceSectionName, isPath: false);

            PackageSource packageSource = null;

            if (settingValues != null && settingValues.Any())
            {
                var setting = settingValues.First();
                if (IsAggregateSource(setting.Key, setting.Value))
                {
                    packageSource = AggregatePackageSource.Instance;
                }
                else
                {
                    packageSource = new PackageSource(setting.Value, setting.Key);
                }
            }

            if (packageSource != null)
            {
                // guard against corrupted data if the active package source is not enabled
                packageSource.IsEnabled = true;
            }

            return(packageSource);
        }
Esempio n. 7
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;
            }
        }
Esempio n. 8
0
        private static void PersistActivePackageSource(
            ISettings settings,
            IVsShellInfo vsShellInfo,
            PackageSource activePackageSource)
        {
            settings.DeleteSection(ActivePackageSourceSectionName);

            if (activePackageSource != null)
            {
                settings.SetValue(ActivePackageSourceSectionName, activePackageSource.Name, activePackageSource.Source);
            }
        }
Esempio n. 9
0
        private PackageSource DeserializeActivePackageSource(
            ISettings settings,
            IVsShellInfo vsShellInfo)
        {
            // NOTE: Even though the aggregate source is being disabled, this method can still return it because
            //  it could be reading a v2.x active source setting. The caller of this method will migrate the active source
            //  to the first enabled feed.

            var enabledSources = new HashSet <string>(StringComparer.CurrentCultureIgnoreCase);

            foreach (var source in _packageSources.Where(p => p.IsEnabled))
            {
                enabledSources.Add(source.Name);
            }

            // The special aggregate source, i.e. "All", is always enabled.
            enabledSources.Add(Resources.VsResources.AggregateSourceName);

            var settingValues = settings.GetValues(ActivePackageSourceSectionName);

            if (settingValues != null)
            {
                settingValues = settingValues.Where(s => enabledSources.Contains(s.Key)).ToList();
            }

            PackageSource packageSource = null;

            if (settingValues != null && settingValues.Any())
            {
                KeyValuePair <string, string> setting = settingValues.First();
                if (IsAggregateSource(setting.Key, setting.Value))
                {
                    packageSource = AggregatePackageSource.Instance;
                }
                else
                {
                    packageSource = new PackageSource(setting.Value, setting.Key);
                }
            }

            if (packageSource != null)
            {
                // guard against corrupted data if the active package source is not enabled
                packageSource.IsEnabled = true;
            }

            return(packageSource);
        }
Esempio n. 10
0
        internal VsPackageSourceProvider(
            ISettings settings,
            IPackageSourceProvider packageSourceProvider,
            IVsShellInfo vsShellInfo)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

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

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

            _packageSourceProvider = packageSourceProvider;
            _settings = settings;
            _vsShellInfo = vsShellInfo;
        }
Esempio n. 11
0
        internal VsPackageSourceProvider(
            ISettings settings,
            IPackageSourceProvider packageSourceProvider,
            IVsShellInfo vsShellInfo)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

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

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

            _packageSourceProvider = packageSourceProvider;
            _settings    = settings;
            _vsShellInfo = vsShellInfo;
        }
Esempio n. 12
0
        private static PackageSource DeserializeActivePackageSource(
            ISettings settings,
            IVsShellInfo vsShellInfo)
        {
            var settingValues = settings.GetValues(ActivePackageSourceSectionName);

            PackageSource packageSource = null;

            if (settingValues != null && settingValues.Any())
            {
                KeyValuePair <string, string> setting = settingValues.First();
                if (IsAggregateSource(setting.Key, setting.Value))
                {
                    packageSource = AggregatePackageSource.Instance;
                }
                else
                {
                    packageSource = new PackageSource(setting.Value, setting.Key);
                }
            }

            if (packageSource != null)
            {
                // guard against corrupted data if the active package source is not enabled
                packageSource.IsEnabled = true;

                // Unlike NuGet Core, Visual Studio has the concept of an official package source.
                // If the active package source is the official source, we need to set its IsOfficial it.
                if (IsOfficialPackageSource(packageSource))
                {
                    packageSource.IsOfficial = true;
                }
            }

            return(packageSource);
        }
Esempio n. 13
0
 public VsPackageSourceProvider(
     ISettings settings,
     IVsShellInfo vsShellInfo) :
     this(settings, new PackageSourceProvider(settings, new[] { NuGetDefaultSource }, _feedsToMigrate), vsShellInfo)
 {
 }
Esempio n. 14
0
        private static void PersistPackageSources(IPackageSourceProvider packageSourceProvider, IVsShellInfo vsShellInfo, List<PackageSource> packageSources)
        {
            bool windows8SourceIsDisabled = false;

            // When running Visual Studio Express For Windows 8, we will have previously added a curated package source.
            // But we don't want to persist it, so remove it from the list.
            if (vsShellInfo.IsVisualStudioExpressForWindows8)
            {
                PackageSource windows8SourceInUse = packageSources.Find(p => p.Equals(Windows8Source));
                Debug.Assert(windows8SourceInUse != null);
                if (windows8SourceInUse != null)
                {
                    packageSources = packageSources.Where(ps => !ps.Equals(Windows8Source)).ToList();
                    windows8SourceIsDisabled = !windows8SourceInUse.IsEnabled;
                }
            }

            // Starting from version 1.3, we persist the package sources to the nuget.config file instead of VS registry.
            // assert that we are not saving aggregate source
            Debug.Assert(!packageSources.Any(p => IsAggregateSource(p.Name, p.Source)));
            
            packageSourceProvider.SavePackageSources(packageSources);

            if (windows8SourceIsDisabled)
            {
                packageSourceProvider.DisablePackageSource(Windows8Source);
            }
        }
Esempio n. 15
0
        private static PackageSource DeserializeActivePackageSource(
            ISettings settings,
            IVsShellInfo vsShellInfo)
        {
            var settingValues = settings.GetValues(ActivePackageSourceSectionName);

            PackageSource packageSource = null;
            if (settingValues != null && settingValues.Any())
            {
                KeyValuePair<string, string> setting = settingValues.First();
                if (IsAggregateSource(setting.Key, setting.Value))
                {
                    packageSource = AggregatePackageSource.Instance;
                }
                else
                {
                    packageSource = new PackageSource(setting.Value, setting.Key);
                }
            }

            if (packageSource != null)
            {
                // guard against corrupted data if the active package source is not enabled
                packageSource.IsEnabled = true;
            }

            return packageSource;
        }
 public VsPackageSourceProvider(
     ISettings settings,            
     IVsShellInfo vsShellInfo) :
     this(settings, vsShellInfo, null)
 {
 }
        private static PackageSource DeserializeActivePackageSource(
            ISettings settings,
            IVsShellInfo vsShellInfo)
        {
            var settingValues = settings.GetValues(ActivePackageSourceSectionName);

            PackageSource packageSource = null;
            if (settingValues != null && settingValues.Any())
            {
                KeyValuePair<string, string> setting = settingValues.First();
                if (IsAggregateSource(setting.Key, setting.Value))
                {
                    packageSource = AggregatePackageSource.Instance;
                }
                else
                {
                    packageSource = new PackageSource(setting.Value, setting.Key);
                }
            }

            if (packageSource != null)
            {
                // guard against corrupted data if the active package source is not enabled
                packageSource.IsEnabled = true;

                // Unlike NuGet Core, Visual Studio has the concept of an official package source. 
                // If the active package source is the official source, we need to set its IsOfficial it.
                if (IsOfficialPackageSource(packageSource))
                {
                    packageSource.IsOfficial = true;
                }
            }

            return packageSource;
        }
Esempio n. 18
0
        private static void PersistPackageSources(IPackageSourceProvider packageSourceProvider, IVsShellInfo vsShellInfo, List<PackageSource> packageSources)
        {
            // When running Visual Studio Express For Windows 8, we will have previously swapped in a curated package source for the normal official source.
            // But, we always want to persist the normal official source. So, we swap the normal official source back in for the curated source.
            if (vsShellInfo.IsVisualStudioExpressForWindows8)
            {
                packageSources = packageSources.Select(packageSource => packageSource.IsOfficial ?
                    new PackageSource(NuGetConstants.DefaultFeedUrl, OfficialFeedName, isEnabled: packageSource.IsEnabled, isOfficial: true) :
                    packageSource)
                    .ToList();
            }

            // Starting from version 1.3, we persist the package sources to the nuget.config file instead of VS registry.
            // assert that we are not saving aggregate source
            Debug.Assert(!packageSources.Any(p => IsAggregateSource(p.Name, p.Source)));
            packageSourceProvider.SavePackageSources(packageSources);
        }
 private static void PersistPackageSources(IPackageSourceProvider packageSourceProvider, IVsShellInfo vsShellInfo, List<PackageSource> packageSources)
 {
     // Starting from version 1.3, we persist the package sources to the nuget.config file instead of VS registry.
     // assert that we are not saving aggregate source
     Debug.Assert(!packageSources.Any(p => IsAggregateSource(p.Name, p.Source)));
     
     packageSourceProvider.SavePackageSources(packageSources);
 }
Esempio n. 20
0
        private static void PersistPackageSources(IPackageSourceProvider packageSourceProvider, IVsShellInfo vsShellInfo, List <PackageSource> packageSources)
        {
            bool windows8SourceIsDisabled = false;

            // When running Visual Studio Express For Windows 8, we will have previously added a curated package source.
            // But we don't want to persist it, so remove it from the list.
            if (vsShellInfo.IsVisualStudioExpressForWindows8)
            {
                PackageSource windows8SourceInUse = packageSources.Find(p => p.Equals(Windows8Source));
                Debug.Assert(windows8SourceInUse != null);
                if (windows8SourceInUse != null)
                {
                    packageSources           = packageSources.Where(ps => !ps.Equals(Windows8Source)).ToList();
                    windows8SourceIsDisabled = !windows8SourceInUse.IsEnabled;
                }
            }

            // Starting from version 1.3, we persist the package sources to the nuget.config file instead of VS registry.
            // assert that we are not saving aggregate source
            Debug.Assert(!packageSources.Any(p => IsAggregateSource(p.Name, p.Source)));

            packageSourceProvider.SavePackageSources(packageSources);

            if (windows8SourceIsDisabled)
            {
                packageSourceProvider.DisablePackageSource(Windows8Source);
            }
        }
Esempio n. 21
0
        private static void PersistActivePackageSource(
            ISettings settings,
            IVsShellInfo vsShellInfo,
            PackageSource activePackageSource)
        {
            if (activePackageSource != null)
            {
                // When running Visual Studio Express For Windows 8, we will have previously swapped in a curated package source for the normal official source.
                // But, we always want to persist the normal official source. So, we swap the normal official source back in for the curated source.
                if (vsShellInfo.IsVisualStudioExpressForWindows8 && activePackageSource.IsOfficial)
                {
                    activePackageSource = new PackageSource(NuGetConstants.DefaultFeedUrl, OfficialFeedName, isEnabled: activePackageSource.IsEnabled, isOfficial: true);
                }

                settings.SetValue(ActivePackageSourceSectionName, activePackageSource.Name, activePackageSource.Source);
            }
            else
            {
                settings.DeleteSection(ActivePackageSourceSectionName);
            }
        }
Esempio n. 22
0
        private static void PersistPackageSources(IPackageSourceProvider packageSourceProvider, IVsShellInfo vsShellInfo, List <PackageSource> packageSources)
        {
            // Starting from version 1.3, we persist the package sources to the nuget.config file instead of VS registry.
            // assert that we are not saving aggregate source
            Debug.Assert(!packageSources.Any(p => IsAggregateSource(p.Name, p.Source)));

            packageSourceProvider.SavePackageSources(packageSources);
        }
        private static void PersistActivePackageSource(
            ISettings settings,
            IVsShellInfo vsShellInfo,
            PackageSource activePackageSource)
        {
            settings.DeleteSection(ActivePackageSourceSectionName);

            if (activePackageSource != null)
            {
                settings.SetValue(ActivePackageSourceSectionName, activePackageSource.Name, activePackageSource.Source);
            }
        }
Esempio n. 24
0
 public VsPackageSourceProvider(
     ISettings settings,
     IVsShellInfo vsShellInfo) :
     this(settings, new PackageSourceProvider(settings, new[] { _defaultSource }, _feedsToMigrate), vsShellInfo)
 {
 }
        private PackageSource DeserializeActivePackageSource(
            ISettings settings,
            IVsShellInfo vsShellInfo)
        {
            // NOTE: Even though the aggregate source is being disabled, this method can still return it because
            //  it could be reading a v2.x active source setting. The caller of this method will migrate the active source
            //  to the first enabled feed.

            var enabledSources = new HashSet<string>(StringComparer.CurrentCultureIgnoreCase);
            foreach (var source in _packageSources.Where(p => p.IsEnabled))
            {
                enabledSources.Add(source.Name);
            }

            // The special aggregate source, i.e. "All", is always enabled.
            enabledSources.Add(Resources.VsResources.AggregateSourceName);

            var settingValues = settings.GetValues(ActivePackageSourceSectionName);
            if (settingValues != null)
            {
                settingValues = settingValues.Where(s => enabledSources.Contains(s.Key)).ToList();
            }

            PackageSource packageSource = null;
            if (settingValues != null && settingValues.Any())
            {
                KeyValuePair<string, string> setting = settingValues.First();
                if (IsAggregateSource(setting.Key, setting.Value))
                {
                    packageSource = AggregatePackageSource.Instance;
                }
                else
                {
                    packageSource = new PackageSource(setting.Value, setting.Key);
                }
            }

            if (packageSource != null)
            {
                // guard against corrupted data if the active package source is not enabled
                packageSource.IsEnabled = true;
            }

            return packageSource;
        }
Esempio n. 26
0
 public VsPackageSourceProvider(
     ISettings settings,
     IVsShellInfo vsShellInfo) :
     this(settings, vsShellInfo, null)
 {
 }
Esempio n. 27
0
        private static PackageSource DeserializeActivePackageSource(
            ISettings settings,
            IVsShellInfo vsShellInfo)
        {
            var settingValues = settings.GetValues(ActivePackageSourceSectionName);

            PackageSource packageSource = null;
            if (settingValues != null && settingValues.Any())
            {
                KeyValuePair<string, string> setting = settingValues.First();
                if (IsAggregateSource(setting.Key, setting.Value))
                {
                    packageSource = AggregatePackageSource.Instance;
                }
                else
                {
                    packageSource = new PackageSource(setting.Value, setting.Key);
                }
            }

            if (packageSource != null)
            {
                // guard against corrupted data if the active package source is not enabled
                packageSource.IsEnabled = true;

                // Unlike NuGet Core, Visual Studio has the concept of an official package source. 
                // If the active package source is the official source, we need to set its IsOfficial it.
                if (IsOfficialPackageSource(packageSource))
                {
                    packageSource.IsOfficial = true;

                    // When running Visual Studio Express for Windows 8, we swap in a curated feed for the normal official feed.
                    if (vsShellInfo.IsVisualStudioExpressForWindows8)
                    {
                        packageSource = new PackageSource(NuGetConstants.VisualStudioExpressForWindows8FeedUrl, VisualStudioExpressForWindows8FeedName, isEnabled: packageSource.IsEnabled, isOfficial: true);
                    }
                }
            }

            return packageSource;
        }