-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for overriding nuspec repository url and version before p…
…ushing nupkg to GPR. Fixes #48
- Loading branch information
Showing
5 changed files
with
304 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Xml.Linq; | ||
|
||
namespace GprTool | ||
{ | ||
public static class NugetExtensions | ||
{ | ||
public static XElement SingleOrDefault([NotNull] this XDocument xDocument, [NotNull] XName name, bool ignoreCase = true, bool ignoreNamespace = true) | ||
{ | ||
if (xDocument == null) throw new ArgumentNullException(nameof(xDocument)); | ||
if (name == null) throw new ArgumentNullException(nameof(name)); | ||
return xDocument.Descendants().SingleOrDefault(name, ignoreCase, ignoreNamespace); | ||
} | ||
|
||
public static XElement SingleOrDefault([NotNull] this XElement xElement, [NotNull] XName name, bool ignoreCase = true, bool ignoreNamespace = true) | ||
{ | ||
if (xElement == null) throw new ArgumentNullException(nameof(xElement)); | ||
if (name == null) throw new ArgumentNullException(nameof(name)); | ||
return xElement.Descendants().SingleOrDefault(name, ignoreCase, ignoreNamespace); | ||
} | ||
|
||
public static XElement SingleOrDefault([NotNull] this IEnumerable<XElement> xElements, [NotNull] XName name, bool ignoreCase = true, bool ignoreNamespace = true) | ||
{ | ||
if (xElements == null) throw new ArgumentNullException(nameof(xElements)); | ||
if (name == null) throw new ArgumentNullException(nameof(name)); | ||
foreach (var node in xElements) | ||
{ | ||
var comperator = ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; | ||
if (!string.Equals(node.Name.LocalName, name.LocalName, comperator)) | ||
{ | ||
continue; | ||
} | ||
|
||
if (!ignoreNamespace && !string.Equals(node.Name.NamespaceName, name.NamespaceName, comperator)) | ||
{ | ||
continue; | ||
} | ||
|
||
return node; | ||
} | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters