public static IEnumerable <PortableProfile> EnumeratePortableProfiles(IFolder folder)
        {
            foreach (var version in folder.EnumerateFolders())
            {
                var profilesFolder = version.Folder("Profile");
                if (profilesFolder == null)
                {
                    continue;
                }
                foreach (var profile in profilesFolder.EnumerateFolders())
                {
                    var versionFileName = Path.GetFileName(version.FullPath.TrimEnd('/'));
                    var profileFileName = Path.GetFileName(profile.FullPath.TrimEnd('/'));
                    var ret             = new PortableProfile
                    {
                        Name = new FrameworkName(".NETPortable", new Version(versionFileName.Substring(1)), profileFileName)
                    };

                    var frameworkListFile = profile.Folder("RedistList").File("FrameworkList.xml");
                    var frameworkList     = XElement.Load(frameworkListFile.Open());
                    ret.DisplayName = frameworkList.Attribute("Name").Value;

                    var supportedFrameworkFolder = profile.Folder("SupportedFrameworks");
                    var supportedFrameworks      = supportedFrameworkFolder.EnumerateFiles();
                    foreach (var supportedFramework in supportedFrameworks)
                    {
                        var xml = XElement.Load(supportedFramework.Open());
                        var maximumVisualStudioVersionAttribute = xml.Attribute("MaximumVisualStudioVersion");
                        var childFramework = new FrameworkProfile
                        {
                            DisplayName = xml.Attribute("DisplayName").Value,
                            Name        = new FrameworkName(xml.Attribute("Identifier").Value, new Version(xml.Attribute("MinimumVersion").Value), xml.Attribute("Profile").Value),
                            MaximumVisualStudioVersion = maximumVisualStudioVersionAttribute == null ? null : new Version(maximumVisualStudioVersionAttribute.Value),
                        };
                        if (!childFramework.IsPrivate)
                        {
                            ret.SupportedFrameworks.Add(childFramework);
                        }
                    }

                    if (ret.SupportedFrameworks.Count > 1)
                    {
                        yield return(ret);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static string GetNugetTarget(FrameworkProfile profile)
        {
            string result;

            if (KnownNugetTargets.TryGetValue(profile.Name, out result))
            {
                return(result);
            }
            string platform;

            if (!KnownNugetPlatforms.TryGetValue(profile.Name.Identifier, out platform))
            {
                return(string.Empty);
            }
            var version = profile.Name.Version.ToString();

            while (version.EndsWith(".0"))
            {
                version = version.Substring(0, version.Length - 2);
            }

            // This is dangerous if any version number goes >= 10, but hey, that's NuGet's problem...
            return(platform + version.Replace(".", string.Empty));
        }