Ejemplo n.º 1
0
        public static TargetFramework FromFrameworkDirectory(TargetFrameworkMoniker moniker, FilePath dir)
        {
            var fxListFile = dir.Combine("RedistList", "FrameworkList.xml");
            var fxListInfo = new FileInfo(fxListFile);

            if (!fxListInfo.Exists)
            {
                return(null);
            }

            var fxCacheDir = UserProfile.Current.CacheDir.Combine("FrameworkInfo");

            var cacheKey = moniker.Identifier + "_" + moniker.Version;

            if (!string.IsNullOrEmpty(moniker.Profile))
            {
                cacheKey += "_" + moniker.Profile;
            }

            FrameworkInfo fxInfo;

            var cachedListFile = fxCacheDir.Combine(cacheKey + ".xml");
            var cachedListInfo = new FileInfo(cachedListFile);

            if (cachedListInfo.Exists && cachedListInfo.LastWriteTime == fxListInfo.LastWriteTime)
            {
                fxInfo = FrameworkInfo.Load(moniker, cachedListFile);
            }
            else
            {
                fxInfo = FrameworkInfo.Load(moniker, fxListFile);
                var supportedFrameworksDir = dir.Combine("SupportedFrameworks");
                if (Directory.Exists(supportedFrameworksDir))
                {
                    foreach (var sfx in Directory.EnumerateFiles(supportedFrameworksDir))
                    {
                        fxInfo.SupportedFrameworks.Add(SupportedFramework.Load(sfx));
                    }
                }
                if (fxInfo.Assemblies.Count == 0)
                {
                    fxInfo.Assemblies = ScanAssemblyDirectory(moniker, fxInfo.TargetFrameworkDirectory);
                }
                Directory.CreateDirectory(fxCacheDir);
                fxInfo.Save(cachedListFile);
                File.SetLastWriteTime(cachedListFile, fxListInfo.LastWriteTime);
            }

            return(new TargetFramework(moniker)
            {
                name = fxInfo.Name,
                includesFramework = fxInfo.IncludeFramework,
                Assemblies = fxInfo.Assemblies.ToArray(),
                supportedFrameworks = fxInfo.SupportedFrameworks,
                FrameworkAssembliesDirectory = fxInfo.TargetFrameworkDirectory
            });
        }
        internal static SupportedFramework Load(TargetFramework target, FilePath path)
        {
            SupportedFramework fx = new SupportedFramework(target);

            fx.DisplayName = path.FileNameWithoutExtension;

            using (var reader = XmlReader.Create(path)) {
                if (!reader.ReadToDescendant("Framework"))
                {
                    throw new Exception("Missing Framework element");
                }

                if (!reader.HasAttributes)
                {
                    throw new Exception("Framework element does not contain any attributes");
                }

                while (reader.MoveToNextAttribute())
                {
                    switch (reader.Name)
                    {
                    case "MaximumVersion":
                        fx.MaximumVersion = ParseVersion(reader.Value, NoMaximumVersion);
                        break;

                    case "MinimumVersion":
                        fx.MinimumVersion = ParseVersion(reader.Value, NoMinumumVersion);
                        break;

                    case "Profile":
                        fx.Profile = reader.Value;
                        break;

                    case "Identifier":
                        fx.Identifier = reader.Value;
                        break;

                    case "MinimumVersionDisplayName":
                        fx.MinimumVersionDisplayName = reader.Value;
                        break;

                    case "DisplayName":
                        fx.DisplayName = reader.Value;
                        break;
                    }
                }
            }

            if (string.IsNullOrEmpty(fx.Identifier))
            {
                throw new Exception("Framework element did not specify an Identifier attribute");
            }

            return(fx);
        }
Ejemplo n.º 3
0
        internal static SupportedFramework LoadFromAttributes(XmlReader reader)
        {
            var fx = new SupportedFramework();

            if (!reader.HasAttributes)
            {
                throw new Exception("Framework element does not contain any attributes");
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                case "MaximumVersion":
                    fx.MaximumVersion = ParseVersion(reader.Value, NoMaximumVersion);
                    break;

                case "MinimumVersion":
                    fx.MinimumVersion = ParseVersion(reader.Value, NoMinimumVersion);
                    break;

                case "Profile":
                    fx.Profile = reader.Value;
                    break;

                case "Identifier":
                    fx.Identifier = reader.Value;
                    break;

                case "MinimumVersionDisplayName":
                    fx.MinimumVersionDisplayName = reader.Value;
                    break;

                case "DisplayName":
                    fx.DisplayName = reader.Value;
                    break;

                case "MonoSpecificVersion":
                    fx.MonoSpecificVersion = reader.Value;
                    break;

                case "MonoSpecificVersionDisplayName":
                    fx.MonoSpecificVersionDisplayName = reader.Value;
                    break;
                }
            }

            if (string.IsNullOrEmpty(fx.Identifier))
            {
                throw new Exception("Framework element did not specify an Identifier attribute");
            }

            return(fx);
        }
		static void InitProfiles ()
		{
			// Profile 1 (.NETFramework + Silverlight + WindowsPhone + Xbox)
			NetPortableProfile1 = Runtime.SystemAssemblyService.GetTargetFramework (new TargetFrameworkMoniker (".NETPortable", "4.0", "Profile1"));
			SupportedFramework NetFramework = new SupportedFramework (NetPortableProfile1, ".NETFramework", ".NET Framework", "*", new Version (4, 0), "4");
			SupportedFramework Silverlight = new SupportedFramework (NetPortableProfile1, "Silverlight", "Silverlight", "", new Version (4, 0), "4");
			SupportedFramework WindowsPhone = new SupportedFramework (NetPortableProfile1, "Silverlight", "Windows Phone", "WindowsPhone*", new Version (4, 0), "7");
			SupportedFramework Xbox = new SupportedFramework (NetPortableProfile1, "Xbox", "Xbox 360", "*", new Version (4, 0), "");
			
			NetPortableProfile1.SupportedFrameworks.Add (NetFramework);
			NetPortableProfile1.SupportedFrameworks.Add (Silverlight);
			NetPortableProfile1.SupportedFrameworks.Add (WindowsPhone);
			NetPortableProfile1.SupportedFrameworks.Add (Xbox);

			// Profile 2 (.NETFramework + Silverlight + WindowsPhone)
			NetPortableProfile2 = Runtime.SystemAssemblyService.GetTargetFramework (new TargetFrameworkMoniker (".NETPortable", "4.0", "Profile2"));
			NetFramework = new SupportedFramework (NetPortableProfile2, ".NETFramework", ".NET Framework", "*", new Version (4, 0), "4");
			Silverlight = new SupportedFramework (NetPortableProfile2, "Silverlight", "Silverlight", "", new Version (4, 0), "4");
			WindowsPhone = new SupportedFramework (NetPortableProfile2, "Silverlight", "Windows Phone", "WindowsPhone*", new Version (4, 0), "7");
			
			NetPortableProfile2.SupportedFrameworks.Add (NetFramework);
			NetPortableProfile2.SupportedFrameworks.Add (Silverlight);
			NetPortableProfile2.SupportedFrameworks.Add (WindowsPhone);

			// Profile 3 (.NETFramework + Silverlight)
			NetPortableProfile3 = Runtime.SystemAssemblyService.GetTargetFramework (new TargetFrameworkMoniker (".NETPortable", "4.0", "Profile3"));
			NetFramework = new SupportedFramework (NetPortableProfile3, ".NETFramework", ".NET Framework", "*", new Version (4, 0), "4");
			Silverlight = new SupportedFramework (NetPortableProfile3, "Silverlight", "Silverlight", "", new Version (4, 0), "4");
			
			NetPortableProfile3.SupportedFrameworks.Add (NetFramework);
			NetPortableProfile3.SupportedFrameworks.Add (Silverlight);

			// Profile 4 (Silverlight + WindowsPhone)
			NetPortableProfile4 = Runtime.SystemAssemblyService.GetTargetFramework (new TargetFrameworkMoniker (".NETPortable", "4.0", "Profile4"));
			Silverlight = new SupportedFramework (NetPortableProfile4, "Silverlight", "Silverlight", "", new Version (4, 0), "4");
			WindowsPhone = new SupportedFramework (NetPortableProfile4, "Silverlight", "Windows Phone", "WindowsPhone*", new Version (4, 0), "7");

			NetPortableProfile4.SupportedFrameworks.Add (Silverlight);
			NetPortableProfile4.SupportedFrameworks.Add (WindowsPhone);
		}
Ejemplo n.º 5
0
        public static TargetFramework FromFrameworkDirectory(TargetFrameworkMoniker moniker, FilePath dir)
        {
            var fxList = dir.Combine("RedistList", "FrameworkList.xml");

            if (!File.Exists(fxList))
            {
                return(null);
            }

            var fx = new TargetFramework(moniker);

            using (var reader = System.Xml.XmlReader.Create(fxList)) {
                if (!reader.ReadToDescendant("FileList"))
                {
                    throw new Exception("Missing FileList element");
                }

                //not sure what this is for
                //if (reader.MoveToAttribute ("Redist") && reader.ReadAttributeValue ())
                //	redist = reader.ReadContentAsString ();

                if (reader.MoveToAttribute("Name") && reader.ReadAttributeValue())
                {
                    fx.name = reader.ReadContentAsString();
                }

                if (reader.MoveToAttribute("RuntimeVersion") && reader.ReadAttributeValue())
                {
                    string runtimeVersion = reader.ReadContentAsString();
                    switch (runtimeVersion)
                    {
                    case "2.0":
                        fx.clrVersion = ClrVersion.Net_2_0;
                        break;

                    case "4.0":
                        fx.clrVersion = ClrVersion.Net_4_0;
                        break;

                    case "4.5":
                    case "4.5.1":
                        fx.clrVersion = ClrVersion.Net_4_5;
                        break;

                    default:
                        LoggingService.LogInfo("Framework {0} has unknown RuntimeVersion {1}", moniker, runtimeVersion);
                        return(null);
                    }
                }

                if (reader.MoveToAttribute("ToolsVersion") && reader.ReadAttributeValue())
                {
                    string toolsVersion = reader.ReadContentAsString();
                    switch (toolsVersion)
                    {
                    case "2.0":
                        fx.toolsVersion = TargetFrameworkToolsVersion.V2_0;
                        break;

                    case "3.5":
                        fx.toolsVersion = TargetFrameworkToolsVersion.V3_5;
                        break;

                    case "4.0":
                        fx.toolsVersion = TargetFrameworkToolsVersion.V4_0;
                        break;

                    case "4.5":
                        fx.toolsVersion = TargetFrameworkToolsVersion.V4_5;
                        break;

                    default:
                        LoggingService.LogInfo("Framework {0} has unknown ToolsVersion {1}", moniker, toolsVersion);
                        return(null);
                    }
                }

                if (reader.MoveToAttribute("IncludeFramework") && reader.ReadAttributeValue())
                {
                    string include = reader.ReadContentAsString();
                    if (!string.IsNullOrEmpty(include))
                    {
                        fx.includesFramework = include;
                    }
                }

                //this is a Mono-specific extension
                if (reader.MoveToAttribute("TargetFrameworkDirectory") && reader.ReadAttributeValue())
                {
                    string targetDir = reader.ReadContentAsString();
                    if (!string.IsNullOrEmpty(targetDir))
                    {
                        targetDir = targetDir.Replace('\\', System.IO.Path.DirectorySeparatorChar);
                        dir       = fxList.ParentDirectory.Combine(targetDir).FullPath;
                    }
                }

                var assemblies = new List <AssemblyInfo> ();
                if (reader.ReadToFollowing("File"))
                {
                    do
                    {
                        var ainfo = new AssemblyInfo();
                        assemblies.Add(ainfo);
                        if (reader.MoveToAttribute("AssemblyName") && reader.ReadAttributeValue())
                        {
                            ainfo.Name = reader.ReadContentAsString();
                        }
                        if (string.IsNullOrEmpty(ainfo.Name))
                        {
                            throw new Exception("Missing AssemblyName attribute");
                        }
                        if (reader.MoveToAttribute("Version") && reader.ReadAttributeValue())
                        {
                            ainfo.Version = reader.ReadContentAsString();
                        }
                        if (reader.MoveToAttribute("PublicKeyToken") && reader.ReadAttributeValue())
                        {
                            ainfo.PublicKeyToken = reader.ReadContentAsString();
                        }
                        if (reader.MoveToAttribute("Culture") && reader.ReadAttributeValue())
                        {
                            ainfo.Culture = reader.ReadContentAsString();
                        }
                        if (reader.MoveToAttribute("ProcessorArchitecture") && reader.ReadAttributeValue())
                        {
                            ainfo.ProcessorArchitecture = (ProcessorArchitecture)
                                                          Enum.Parse(typeof(ProcessorArchitecture), reader.ReadContentAsString(), true);
                        }
                        if (reader.MoveToAttribute("InGac") && reader.ReadAttributeValue())
                        {
                            ainfo.InGac = reader.ReadContentAsBoolean();
                        }
                    } while (reader.ReadToFollowing("File"));
                }
                else
                {
                    // HACK: we were using EnumerateFiles but it's broken in some Mono releases
                    // https://bugzilla.xamarin.com/show_bug.cgi?id=2975
                    var files = Directory.GetFiles(dir, "*.dll");
                    foreach (var f in files)
                    {
                        try {
                            var an    = SystemAssemblyService.GetAssemblyNameObj(dir.Combine(f));
                            var ainfo = new AssemblyInfo();
                            ainfo.Update(an);
                            assemblies.Add(ainfo);
                        } catch (Exception ex) {
                            LoggingService.LogError("Error reading name for assembly '{0}' in framework '{1}':\n{2}",
                                                    f, fx.Id, ex.ToString());
                        }
                    }
                }

                fx.Assemblies = assemblies.ToArray();
            }

            var supportedFrameworksDir = dir.Combine("SupportedFrameworks");

            if (Directory.Exists(supportedFrameworksDir))
            {
                foreach (var sfx in Directory.GetFiles(supportedFrameworksDir))
                {
                    fx.SupportedFrameworks.Add(SupportedFramework.Load(fx, sfx));
                }
            }

            return(fx);
        }
Ejemplo n.º 6
0
        public static FrameworkInfo Load(TargetFrameworkMoniker moniker, FilePath frameworkListFile)
        {
            var info = new FrameworkInfo {
                Id = moniker
            };

            //for non-cached files, this file is in the RedistList subdir of the assembly dir
            info.TargetFrameworkDirectory = frameworkListFile.ParentDirectory.ParentDirectory;

            using (var reader = XmlReader.Create(frameworkListFile)) {
                if (!reader.ReadToDescendant("FileList"))
                {
                    throw new Exception("Missing FileList element");
                }

                if (reader.MoveToAttribute("Name") && reader.ReadAttributeValue())
                {
                    info.Name = reader.ReadContentAsString();
                }

                if (reader.MoveToAttribute("IncludeFramework") && reader.ReadAttributeValue())
                {
                    string include = reader.ReadContentAsString();
                    if (!string.IsNullOrEmpty(include))
                    {
                        info.IncludeFramework = include;
                    }
                }

                //this is a Mono-specific extension
                if (reader.MoveToAttribute("TargetFrameworkDirectory") && reader.ReadAttributeValue())
                {
                    string targetDir = reader.ReadContentAsString();
                    if (!string.IsNullOrEmpty(targetDir))
                    {
                        targetDir = targetDir.Replace('\\', Path.DirectorySeparatorChar);
                        info.TargetFrameworkDirectory = frameworkListFile.ParentDirectory.Combine(targetDir).FullPath;
                    }
                }

                info.Assemblies          = new List <AssemblyInfo> ();
                info.SupportedFrameworks = new List <SupportedFramework> ();

                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        switch (reader.LocalName)
                        {
                        case "File":
                            info.Assemblies.Add(ReadFileElement(reader));
                            break;

                        case "SupportedFramework":
                            info.SupportedFrameworks.Add(SupportedFramework.LoadFromAttributes(reader));
                            break;
                        }
                    }
                }
            }
            return(info);
        }
			public OptionComboItem (string name, SupportedFramework sfx)
			{
				this.Name = name;
				this.Framework = sfx;
				this.Targets = new List<TargetFramework> ();
			}
		void SelectOption (SupportedFramework sfx)
		{
			foreach (var option in options) {
				for (int i = 0; i < option.Items.Count; i++) {
					var item = option.Items [i];
					if (!item.Framework.Equals (sfx))
						continue;

					option.Check.Active = true;
					if (option.Combo != null)
						option.Combo.Active = i;
					return;
				}
			}

			throw new InvalidOperationException ();
		}
		static string GetShortName (SupportedFramework sfx)
		{
			switch (sfx.DisplayName) {
			case ".NET Framework":
				return "NET" + sfx.MinimumVersionDisplayName.Replace (".", "");
			case "Silverlight":
				return "SL" + sfx.MinimumVersionDisplayName;
			case "Xamarin.Android":
				return "Android";
			case ".NET for Windows Store apps":
				return "WinStore";
			case "Windows Phone":
				return "WP" + sfx.MinimumVersionDisplayName.Replace (".", "");
			case "Xbox 360":
				return "XBox";
			case "Xamarin.iOS":
				if (string.IsNullOrEmpty (sfx.MonoSpecificVersionDisplayName))
					return "iOS";
				else
					return "iOS/" + sfx.MonoSpecificVersion;
			default:
				return GetDisplayName (sfx);
			}
		}
		static string GetDisplayName (SupportedFramework sfx)
		{
			if (!string.IsNullOrEmpty (sfx.MinimumVersionDisplayName))
				return sfx.DisplayName + " " + sfx.MinimumVersionDisplayName;
			else if (!string.IsNullOrEmpty (sfx.MonoSpecificVersionDisplayName))
				return sfx.DisplayName + " " + sfx.MonoSpecificVersionDisplayName;
			else
				return sfx.DisplayName;
		}
		internal static SupportedFramework Load (TargetFramework target, FilePath path)
		{
			SupportedFramework fx = new SupportedFramework (target);

			fx.DisplayName = path.FileNameWithoutExtension;
			
			using (var reader = XmlReader.Create (path)) {
				if (!reader.ReadToDescendant ("Framework"))
					throw new Exception ("Missing Framework element");
				
				if (!reader.HasAttributes)
					throw new Exception ("Framework element does not contain any attributes");
				
				while (reader.MoveToNextAttribute ()) {
					switch (reader.Name) {
					case "MaximumVersion":
						fx.MaximumVersion = ParseVersion (reader.Value, NoMaximumVersion);
						break;
					case "MinimumVersion":
						fx.MinimumVersion = ParseVersion (reader.Value, NoMinumumVersion);
						break;
					case "Profile":
						fx.Profile = reader.Value;
						break;
					case "Identifier":
						fx.Identifier = reader.Value;
						break;
					case "MinimumVersionDisplayName":
						fx.MinimumVersionDisplayName = reader.Value;
						break;
					case "DisplayName":
						fx.DisplayName = reader.Value;
						break;
					}
				}
			}

			if (string.IsNullOrEmpty (fx.Identifier))
				throw new Exception ("Framework element did not specify an Identifier attribute");
			
			return fx;
		}
Ejemplo n.º 12
0
        public static TargetFramework FromFrameworkDirectory(TargetFrameworkMoniker moniker, FilePath dir)
        {
            var fxListFile = dir.Combine("RedistList", "FrameworkList.xml");
            var fxListInfo = new FileInfo(fxListFile);

            if (!fxListInfo.Exists)
            {
                return(null);
            }

            var fxCacheDir = UserProfile.Current.CacheDir.Combine("FrameworkInfo");

            var cacheKey = moniker.Identifier + "_" + moniker.Version;

            if (!string.IsNullOrEmpty(moniker.Profile))
            {
                cacheKey += "_" + moniker.Profile;
            }

            FrameworkInfo fxInfo = null;

            var cachedListFile = fxCacheDir.Combine(cacheKey + ".xml");
            var cachedListInfo = new FileInfo(cachedListFile);

            if (cachedListInfo.Exists && cachedListInfo.LastWriteTime == fxListInfo.LastWriteTime)
            {
                fxInfo = FrameworkInfo.Load(moniker, cachedListFile);
                //if Mono was upgraded since caching, the cached location may no longer be valid
                if (!Directory.Exists(fxInfo.TargetFrameworkDirectory))
                {
                    fxInfo = null;
                }
                else if (fxInfo.SupportedFrameworks.Count > 0)
                {
                    // Ensure DisplayName was saved for the SupportedFrameworks. If missing invalidate the
                    // cache to ensure DisplayName is saved. Only check the first framework since the
                    // DisplayName was not being saved previously. The DisplayName will not be empty when
                    // saved even if the framework .xml file does not define it since the filename will be
                    // used as the DisplayName in that case.
                    if (string.IsNullOrEmpty(fxInfo.SupportedFrameworks [0].DisplayName))
                    {
                        fxInfo = null;
                    }
                }
            }

            if (fxInfo == null)
            {
                fxInfo = FrameworkInfo.Load(moniker, fxListFile);
                var supportedFrameworksDir = dir.Combine("SupportedFrameworks");
                if (Directory.Exists(supportedFrameworksDir))
                {
                    foreach (var sfx in Directory.EnumerateFiles(supportedFrameworksDir))
                    {
                        fxInfo.SupportedFrameworks.Add(SupportedFramework.Load(sfx));
                    }
                }
                if (fxInfo.Assemblies.Count == 0)
                {
                    fxInfo.Assemblies = ScanAssemblyDirectory(moniker, fxInfo.TargetFrameworkDirectory);
                }
                Directory.CreateDirectory(fxCacheDir);
                fxInfo.Save(cachedListFile);
                File.SetLastWriteTime(cachedListFile, fxListInfo.LastWriteTime);
            }

            return(new TargetFramework(moniker)
            {
                name = fxInfo.Name,
                includesFramework = fxInfo.IncludeFramework,
                Assemblies = fxInfo.Assemblies.ToArray(),
                supportedFrameworks = fxInfo.SupportedFrameworks,
                FrameworkAssembliesDirectory = fxInfo.TargetFrameworkDirectory
            });
        }
Ejemplo n.º 13
0
        public static TargetFramework FromFrameworkDirectory(TargetFrameworkMoniker moniker, FilePath dir)
        {
            var fxList = dir.Combine("RedistList", "FrameworkList.xml");

            if (!File.Exists(fxList))
            {
                return(null);
            }

            var fx = new TargetFramework(moniker);

            using (var reader = System.Xml.XmlReader.Create(fxList)) {
                if (!reader.ReadToDescendant("FileList"))
                {
                    throw new Exception("Missing FileList element");
                }

                //not sure what this is for
                //if (reader.MoveToAttribute ("Redist") && reader.ReadAttributeValue ())
                //	redist = reader.ReadContentAsString ();

                if (reader.MoveToAttribute("Name") && reader.ReadAttributeValue())
                {
                    fx.name = reader.ReadContentAsString();
                }

                if (reader.MoveToAttribute("IncludeFramework") && reader.ReadAttributeValue())
                {
                    string include = reader.ReadContentAsString();
                    if (!string.IsNullOrEmpty(include))
                    {
                        fx.includesFramework = include;
                    }
                }

                //this is a Mono-specific extension
                if (reader.MoveToAttribute("TargetFrameworkDirectory") && reader.ReadAttributeValue())
                {
                    string targetDir = reader.ReadContentAsString();
                    if (!string.IsNullOrEmpty(targetDir))
                    {
                        targetDir = targetDir.Replace('\\', System.IO.Path.DirectorySeparatorChar);
                        dir       = fxList.ParentDirectory.Combine(targetDir).FullPath;
                    }
                }

                var assemblies = new List <AssemblyInfo> ();
                if (reader.ReadToFollowing("File"))
                {
                    do
                    {
                        var ainfo = new AssemblyInfo();
                        assemblies.Add(ainfo);
                        if (reader.MoveToAttribute("AssemblyName") && reader.ReadAttributeValue())
                        {
                            ainfo.Name = reader.ReadContentAsString();
                        }
                        if (string.IsNullOrEmpty(ainfo.Name))
                        {
                            throw new Exception("Missing AssemblyName attribute");
                        }
                        if (reader.MoveToAttribute("Version") && reader.ReadAttributeValue())
                        {
                            ainfo.Version = reader.ReadContentAsString();
                        }
                        if (reader.MoveToAttribute("PublicKeyToken") && reader.ReadAttributeValue())
                        {
                            ainfo.PublicKeyToken = reader.ReadContentAsString();
                        }
                        if (reader.MoveToAttribute("Culture") && reader.ReadAttributeValue())
                        {
                            ainfo.Culture = reader.ReadContentAsString();
                        }
                        if (reader.MoveToAttribute("ProcessorArchitecture") && reader.ReadAttributeValue())
                        {
                            ainfo.ProcessorArchitecture = (ProcessorArchitecture)
                                                          Enum.Parse(typeof(ProcessorArchitecture), reader.ReadContentAsString(), true);
                        }
                        if (reader.MoveToAttribute("InGac") && reader.ReadAttributeValue())
                        {
                            ainfo.InGac = reader.ReadContentAsBoolean();
                        }
                    } while (reader.ReadToFollowing("File"));
                }
                else if (Directory.Exists(dir))
                {
                    foreach (var f in Directory.EnumerateFiles(dir, "*.dll"))
                    {
                        try {
                            var an    = SystemAssemblyService.GetAssemblyNameObj(dir.Combine(f));
                            var ainfo = new AssemblyInfo();
                            ainfo.Update(an);
                            assemblies.Add(ainfo);
                        } catch (BadImageFormatException ex) {
                            LoggingService.LogError("Invalid assembly in framework '{0}': {1}{2}{3}", fx.Id, f, Environment.NewLine, ex.ToString());
                        } catch (Exception ex) {
                            LoggingService.LogError("Error reading assembly '{0}' in framework '{1}':{2}{3}",
                                                    f, fx.Id, Environment.NewLine, ex.ToString());
                        }
                    }
                }

                fx.Assemblies = assemblies.ToArray();
            }

            var supportedFrameworksDir = dir.Combine("SupportedFrameworks");

            if (Directory.Exists(supportedFrameworksDir))
            {
                foreach (var sfx in Directory.GetFiles(supportedFrameworksDir))
                {
                    fx.SupportedFrameworks.Add(SupportedFramework.Load(fx, sfx));
                }
            }

            return(fx);
        }