コード例 #1
0
        public void UpdatePackageSources(IEnumerable <PackageSource> updatedPackageSources)
        {
            PackageSources.Clear();
            foreach (PackageSource updatedPackageSource in updatedPackageSources)
            {
                PackageSources.Add(updatedPackageSource);
            }

            UpdateActivePackageSource();
        }
コード例 #2
0
        public void UpdatePackageSources(IEnumerable <PackageSource> updatedPackageSources)
        {
            List <PackageSource> packageSourcesBackup = PackageSources.ToList();

            try {
                PackageSources.Clear();
                foreach (PackageSource updatedPackageSource in updatedPackageSources)
                {
                    PackageSources.Add(updatedPackageSource);
                }

                UpdateActivePackageSource();
            } catch (Exception) {
                PackageSources.AddRange(packageSourcesBackup);
                UpdateActivePackageSource();

                throw;
            }
        }
コード例 #3
0
        protected void InitializePackageSources()
        {
            var settings = Settings.LoadDefaultSettings(new PhysicalFileSystem("C:\\"), null, null);
            var packageSourceProvider = new PackageSourceProvider(settings);
            var packageSources        = packageSourceProvider.GetEnabledPackageSources().ToList();

            HttpClient.DefaultCredentialProvider = new SettingsCredentialProvider(new DotPeekCredentialProvider(), packageSourceProvider);

            if (!packageSources.Any())
            {
                packageSources.Add(PluginConstants.NuGetPackageSource);
            }

            foreach (var packageSource in packageSources)
            {
                PackageSources.Add(new Uri(packageSource.Source));
            }

            PackageSource = PackageSources.First();
        }