Don't return if no volatile feeds are found.

This commit is contained in:
Pranav K 2016-02-18 10:26:58 -08:00
parent 53eb708a8b
commit 03266b4b2a
2 changed files with 32 additions and 36 deletions

View File

@ -10,27 +10,25 @@ use namespace="System.Xml.Linq"
.Select(entry => new KeyValuePair<string, string>(((string)entry.Key).Substring(prefix.Length), (string)entry.Value))
.ToList();
if (!feeds.Any())
if (feeds.Any())
{
return;
}
var nugetConfig = XDocument.Load("NuGet.config");
var packageSources = nugetConfig.Element("configuration").Element("packageSources");
var addElements = packageSources.Elements("add").ToList();
foreach (var feed in feeds)
{
var valueToUpdate = addElements.FirstOrDefault(f => string.Equals(f.Attribute("key").Value, feed.Key, StringComparison.OrdinalIgnoreCase));
if (valueToUpdate == null)
var nugetConfig = XDocument.Load("NuGet.config");
var packageSources = nugetConfig.Element("configuration").Element("packageSources");
var addElements = packageSources.Elements("add").ToList();
foreach (var feed in feeds)
{
packageSources.Add(new XElement("add", new XAttribute("key", feed.Key), new XAttribute("value", feed.Value)));
}
else
{
valueToUpdate.Attribute("value").Value = feed.Value;
var valueToUpdate = addElements.FirstOrDefault(f => string.Equals(f.Attribute("key").Value, feed.Key, StringComparison.OrdinalIgnoreCase));
if (valueToUpdate == null)
{
packageSources.Add(new XElement("add", new XAttribute("key", feed.Key), new XAttribute("value", feed.Value)));
}
else
{
valueToUpdate.Attribute("value").Value = feed.Value;
}
}
nugetConfig.Save("NuGet.config");
}
nugetConfig.Save("NuGet.config");
}

View File

@ -10,27 +10,25 @@ use namespace="System.Xml.Linq"
.Select(entry => new KeyValuePair<string, string>(((string)entry.Key).Substring(prefix.Length), (string)entry.Value))
.ToList();
if (!feeds.Any())
if (feeds.Any())
{
return;
}
var nugetConfig = XDocument.Load("NuGet.config");
var packageSources = nugetConfig.Element("configuration").Element("packageSources");
var addElements = packageSources.Elements("add").ToList();
foreach (var feed in feeds)
{
var valueToUpdate = addElements.FirstOrDefault(f => string.Equals(f.Attribute("key").Value, feed.Key, StringComparison.OrdinalIgnoreCase));
if (valueToUpdate == null)
var nugetConfig = XDocument.Load("NuGet.config");
var packageSources = nugetConfig.Element("configuration").Element("packageSources");
var addElements = packageSources.Elements("add").ToList();
foreach (var feed in feeds)
{
packageSources.Add(new XElement("add", new XAttribute("key", feed.Key), new XAttribute("value", feed.Value)));
}
else
{
valueToUpdate.Attribute("value").Value = feed.Value;
var valueToUpdate = addElements.FirstOrDefault(f => string.Equals(f.Attribute("key").Value, feed.Key, StringComparison.OrdinalIgnoreCase));
if (valueToUpdate == null)
{
packageSources.Add(new XElement("add", new XAttribute("key", feed.Key), new XAttribute("value", feed.Value)));
}
else
{
valueToUpdate.Attribute("value").Value = feed.Value;
}
}
nugetConfig.Save("NuGet.config");
}
nugetConfig.Save("NuGet.config");
}