Skip to content
This repository was archived by the owner on Dec 18, 2017. It is now read-only.

Commit

Permalink
Walk back a part of the latest ManifestReader change
Browse files Browse the repository at this point in the history
Ignore the xml namespace when reading nuspec. There are nuget packages out there without default namespace at root
  • Loading branch information
troydai committed Jul 8, 2015
1 parent a5c7125 commit a875681
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ internal static class ManifestReader

public static Manifest ReadManifest(XDocument document)
{
var schemaNamespace = document.Root.GetDefaultNamespace();
var metadataElement = document.Root.Elements(schemaNamespace + "metadata").FirstOrDefault();
var metadataElement = document.Root.ElementsNoNamespace("metadata").FirstOrDefault();
if (metadataElement == null)
{
throw new InvalidDataException(
Expand All @@ -29,7 +28,7 @@ public static Manifest ReadManifest(XDocument document)

return new Manifest(
ReadMetadata(metadataElement),
ReadFilesList(document.Root.Elements(schemaNamespace + "files").FirstOrDefault()));
ReadFilesList(document.Root.ElementsNoNamespace("files").FirstOrDefault()));
}

private static ManifestMetadata ReadMetadata(XElement xElement)
Expand Down Expand Up @@ -167,7 +166,7 @@ private static List<PackageReferenceSet> ReadReferenceSets(XElement referencesEl

public static List<string> ReadReference(XElement referenceElement, bool throwIfEmpty)
{
var references = referenceElement.Elements(referenceElement.GetDefaultNamespace() + "reference")
var references = referenceElement.ElementsNoNamespace("reference")
.Select(element => ((string)element.Attribute("file"))?.Trim())
.Where(file => file != null)
.ToList();
Expand All @@ -187,7 +186,7 @@ private static List<FrameworkAssemblyReference> ReadFrameworkAssemblies(XElement
return new List<FrameworkAssemblyReference>(0);
}

return frameworkElement.Elements(frameworkElement.GetDefaultNamespace() + "frameworkAssembly")
return frameworkElement.ElementsNoNamespace("frameworkAssembly")
.Where(element => element.Attribute("assemblyName") != null)
.Select(element =>
{
Expand Down

0 comments on commit a875681

Please sign in to comment.