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; } }