public static Manifest ReadFrom(Stream stream, IPropertyProvider propertyProvider, bool validateSchema) { XDocument document = !ReferenceEquals(propertyProvider, NullPropertyProvider.Instance) ? XDocument.Parse(Preprocessor.Process(stream, propertyProvider, true)) : XmlUtility.LoadSafe(stream, true); string schemaNamespace = GetSchemaNamespace(document); foreach (XElement local1 in document.Descendants()) { local1.Name = XName.Get(local1.Name.LocalName, schemaNamespace); } CheckSchemaVersion(document); if (validateSchema) { ValidateManifestSchema(document, schemaNamespace); } Manifest manifest = ManifestReader.ReadManifest(document); Validate(manifest); return(manifest); }
internal static FrameworkName LoadSupportedFramework(Stream stream) { try { var document = XmlUtility.LoadSafe(stream); var root = document.Root; if (root.Name.LocalName.Equals("Framework", StringComparison.Ordinal)) { string identifer = root.GetOptionalAttributeValue("Identifier"); if (identifer == null) { return(null); } string versionString = root.GetOptionalAttributeValue("MinimumVersion"); if (versionString == null) { return(null); } Version version; if (!Version.TryParse(versionString, out version)) { return(null); } string profile = root.GetOptionalAttributeValue("Profile"); if (profile == null) { profile = ""; } if (profile.EndsWith("*", StringComparison.Ordinal)) { profile = profile.Substring(0, profile.Length - 1); // special case, if it was 'WindowsPhone7*', we want it to be WindowsPhone71 if (profile.Equals("WindowsPhone7", StringComparison.OrdinalIgnoreCase)) { profile = "WindowsPhone71"; } else if (identifer.Equals("Silverlight", StringComparison.OrdinalIgnoreCase) && profile.Equals("WindowsPhone", StringComparison.OrdinalIgnoreCase) && version == new Version(4, 0)) { // Since the beginning of NuGet, we have been using "SL3-WP" as the moniker to target WP7 project. // However, it's been discovered recently that the real TFM for WP7 project is "Silverlight, Version=4.0, Profile=WindowsPhone". // This is how the Portable Library xml describes a WP7 platform, as shown here: // // <Framework // Identifier="Silverlight" // Profile="WindowsPhone*" // MinimumVersion="4.0" // DisplayName="Windows Phone" // MinimumVersionDisplayName="7" /> // // To maintain consistent behavior with previous versions of NuGet, we want to change it back to "SL3-WP" nonetheless. version = new Version(3, 0); } } return(new FrameworkName(identifer, version, profile)); } } catch (XmlException) { } catch (IOException) { } catch (SecurityException) { } return(null); }
internal static FrameworkName LoadSupportedFramework(Stream stream) { try { XElement root = XmlUtility.LoadSafe(stream).Root; if (root.Name.LocalName.Equals("Framework", StringComparison.Ordinal)) { FrameworkName name; string str = root.GetOptionalAttributeValue("Identifier", null); if (str == null) { name = null; } else { string input = root.GetOptionalAttributeValue("MinimumVersion", null); if (input == null) { name = null; } else { Version version; if (!Version.TryParse(input, out version)) { name = null; } else { string str3 = root.GetOptionalAttributeValue("Profile", null); if (str3 == null) { str3 = ""; } if (str3.EndsWith("*", StringComparison.Ordinal)) { str3 = str3.Substring(0, str3.Length - 1); if (str3.Equals("WindowsPhone7", StringComparison.OrdinalIgnoreCase)) { str3 = "WindowsPhone71"; } else if (str.Equals("Silverlight", StringComparison.OrdinalIgnoreCase) && (str3.Equals("WindowsPhone", StringComparison.OrdinalIgnoreCase) && (version == new Version(4, 0)))) { version = new Version(3, 0); } } name = new FrameworkName(str, version, str3); } } } return(name); } } catch (XmlException) { } catch (IOException) { } catch (SecurityException) { } return(null); }