public override bool SupportsFramework (TargetFramework framework) { if (!framework.IsCompatibleWithFramework (TargetFrameworkMoniker.PORTABLE_4_0)) return false; else return base.SupportsFramework (framework); }
PortableProfileViewModel CreatePortableProfileViewModel ( TargetFramework fx, IEnumerable<TargetFrameworkMoniker> selectedTargetFrameworks) { bool enabled = selectedTargetFrameworks.Contains (fx.Id); return new PortableProfileViewModel (fx, enabled); }
public override bool SupportsFramework(MonoDevelop.Core.Assemblies.TargetFramework framework) { if (!framework.IsCompatibleWithFramework (MonoDevelop.Core.Assemblies.TargetFrameworkMoniker.NET_4_0)) return false; else return base.SupportsFramework (framework); }
public override string GetAssemblyLocation (string assemblyName, string package, TargetFramework fx) { string loc = base.GetAssemblyLocation (assemblyName, package, fx); if (loc != null) return loc; string baseDirectory = AppDomain.CurrentDomain.BaseDirectory; string name; int i = assemblyName.IndexOf (','); if (i == -1) name = assemblyName; else name = assemblyName.Substring (0,i).Trim (); // Look in initial path if (!string.IsNullOrEmpty (baseDirectory)) { string localPath = Path.Combine (baseDirectory, name); if (File.Exists (localPath)) return localPath; } // Look in assembly directories foreach (string path in GetAssemblyDirectories ()) { string localPath = Path.Combine (path, name); if (File.Exists (localPath)) return localPath; } // Look in the gac return GetGacFile (assemblyName, true); }
public IEnumerable<SystemPackage> GetPackages (TargetFramework fx) { foreach (IAssemblyContext ctx in sources) { foreach (SystemPackage p in ctx.GetPackages (fx)) yield return p; } }
public MonoMacExecutionCommand (TargetRuntime runtime, TargetFramework framework, FilePath appPath, FilePath launchScript, bool debugMode) { this.AppPath = appPath; this.LaunchScript = launchScript; this.Framework = framework; this.Runtime = runtime; this.DebugMode = debugMode; }
public override bool SupportsFramework (TargetFramework framework) { // DotNetAssemblyProject can only generate assemblies for the regular framework. // Special frameworks such as Moonlight or MonoTouch must subclass DotNetProject directly. if (!framework.IsCompatibleWithFramework (TargetFrameworkMoniker.NET_1_1)) return false; else return base.SupportsFramework (framework); }
public PortableRuntimeOptionsPanelWidget(PortableDotNetProject project, IEnumerable<ItemConfiguration> configurations) { this.target = project.TargetFramework; this.project = project; this.Build (); // Aggregate all SupportedFrameworks from .NETPortable TargetFrameworks targetFrameworks = GetPortableTargetFrameworks ().ToList (); targetFrameworks.Sort (CompareFrameworks); supportedFrameworks = new SortedDictionary<string, List<SupportedFramework>> (); if (!targetFrameworks.Contains (project.TargetFramework)) { missingFramework = project.TargetFramework; targetFrameworks.Insert (0, project.TargetFramework); } foreach (var fx in targetFrameworks) { foreach (var sfx in fx.SupportedFrameworks) { List<SupportedFramework> list; if (!supportedFrameworks.TryGetValue (sfx.DisplayName, out list)) { list = new List<SupportedFramework> (); supportedFrameworks.Add (sfx.DisplayName, list); } list.Add (sfx); } } // Now create a list of config options from our supported frameworks options = new List<OptionCombo> (); foreach (var fx in supportedFrameworks) { var combo = new OptionCombo (fx.Key); var dict = new SortedDictionary<string, OptionComboItem> (); foreach (var sfx in fx.Value) { var label = GetDisplayName (sfx); OptionComboItem item; if (!dict.TryGetValue (label, out item)) { item = new OptionComboItem (label, sfx); dict.Add (label, item); } item.Targets.Add (sfx.TargetFramework); } combo.Items = dict.Values.ToList (); options.Add (combo); } CreateUI (); CurrentProfileChanged (project.TargetFramework); }
public override bool SupportsFramework (TargetFramework framework) { if (framework.Id.Identifier == TargetFrameworkMoniker.ID_PORTABLE && framework.Id.Version == "4.0") return true; if (!framework.CanReferenceAssembliesTargetingFramework (TargetFrameworkMoniker.PORTABLE_4_0)) return false; return base.SupportsFramework (framework); }
public SupportedFramework (TargetFramework target, string identifier, string display, string profile, Version minVersion, string minDisplayVersion) { MinimumVersionDisplayName = minDisplayVersion; MinimumVersion = minVersion; MaximumVersion = NoMaximumVersion; DisplayName = display; Identifier = identifier; Profile = profile; TargetFramework = target; }
internal static string GetFxVersion (TargetFramework fx) { switch (fx.Id) { case "SL2.0": return "2.0"; case "SL3.0": return "3.0"; default: throw new InvalidOperationException ("Cannot handle unknown target framework '" + fx.Id +"'"); } }
internal SupportedFramework (TargetFramework target) { MinimumVersionDisplayName = string.Empty; MinimumVersion = NoMinumumVersion; MaximumVersion = NoMaximumVersion; DisplayName = string.Empty; Identifier = string.Empty; Profile = string.Empty; TargetFramework = target; }
public override bool SupportsFramework(MonoDevelop.Core.Assemblies.TargetFramework framework) { if (!framework.CanReferenceAssembliesTargetingFramework(MonoDevelop.Core.Assemblies.TargetFrameworkMoniker.NET_4_0)) { return(false); } else { return(base.SupportsFramework(framework)); } }
public MonoDroidExecutionCommand (string packageName, FilePath apkPath, TargetRuntime runtime, TargetFramework framework, bool debugMode) { this.PackageName = packageName; this.ApkPath = apkPath; this.Runtime = runtime; this.Framework = framework; this.DebugMode = debugMode; DebugPort = MonoDroidSettings.DebuggerPort; OutputPort = MonoDroidSettings.DebuggerOutputPort; }
public void LoadFrom (FilePath assemblyPath) { FileName = assemblyPath; var tid = Runtime.SystemAssemblyService.GetTargetFrameworkForAssembly (Runtime.SystemAssemblyService.DefaultRuntime, assemblyPath); if (tid != null) targetFramework = Runtime.SystemAssemblyService.GetTargetFramework (tid); AssemblyDefinition adef = AssemblyDefinition.ReadAssembly (assemblyPath); MdbReaderProvider mdbProvider = new MdbReaderProvider (); try { ISymbolReader reader = mdbProvider.GetSymbolReader (adef.MainModule, assemblyPath); adef.MainModule.ReadSymbols (reader); } catch { // Ignore } var files = new HashSet<FilePath> (); foreach (TypeDefinition type in adef.MainModule.Types) { foreach (MethodDefinition met in type.Methods) { if (met.HasBody && met.Body.Instructions != null && met.Body.Instructions.Count > 0) { SequencePoint sp = met.Body.Instructions[0].SequencePoint; if (sp != null) files.Add (sp.Document.Url); } } } FilePath rootPath = FilePath.Empty; foreach (FilePath file in files) { AddFile (file, BuildAction.Compile); if (rootPath.IsNullOrEmpty) rootPath = file.ParentDirectory; else if (!file.IsChildPathOf (rootPath)) rootPath = FindCommonRoot (rootPath, file); } if (!rootPath.IsNullOrEmpty) BaseDirectory = rootPath; /* foreach (AssemblyNameReference aref in adef.MainModule.AssemblyReferences) { if (aref.Name == "mscorlib") continue; string asm = assemblyPath.ParentDirectory.Combine (aref.Name); if (File.Exists (asm + ".dll")) References.Add (new ProjectReference (ReferenceType.Assembly, asm + ".dll")); else if (File.Exists (asm + ".exe")) References.Add (new ProjectReference (ReferenceType.Assembly, asm + ".exe")); else References.Add (new ProjectReference (ReferenceType.Package, aref.FullName)); }*/ }
static ProjectDom GetSystemWebDom (TargetRuntime runtime, TargetFramework targetFramework) { string file = runtime.AssemblyContext.GetAssemblyNameForVersion (sysWebAssemblyName, targetFramework); if (string.IsNullOrEmpty (file)) throw new Exception ("System.Web assembly name not found for framework " + targetFramework.Id); file = runtime.AssemblyContext.GetAssemblyLocation (file, targetFramework); if (string.IsNullOrEmpty (file)) throw new Exception ("System.Web assembly file not found for framework " + targetFramework.Id); ProjectDom dom = ProjectDomService.GetAssemblyDom (runtime, file); if (dom == null) throw new Exception ("System.Web parse database not found for framework " + targetFramework.Id + " file '" + file + "'"); return dom; }
public IPhoneExecutionCommand (TargetRuntime runtime, TargetFramework framework, FilePath appPath, FilePath logDirectory, bool debugMode, IPhoneSimulatorTarget target, IPhoneSdkVersion minimumOSVersion, TargetDevice supportedDevices) { this.AppPath = appPath; this.LogDirectory = logDirectory; this.Framework = framework; this.Runtime = runtime; this.DebugMode = debugMode; this.SimulatorTarget = target; this.MinimumOSVersion = minimumOSVersion; this.SupportedDevices = supportedDevices; }
static ICompilation GetSystemWebDom (TargetRuntime runtime, TargetFramework targetFramework) { string file = runtime.AssemblyContext.GetAssemblyNameForVersion (sysWebAssemblyName, targetFramework); if (string.IsNullOrEmpty (file)) throw new Exception ("System.Web assembly name not found for framework " + targetFramework.Id); file = runtime.AssemblyContext.GetAssemblyLocation (file, targetFramework); if (string.IsNullOrEmpty (file)) throw new Exception ("System.Web assembly file not found for framework " + targetFramework.Id); var dom = new SimpleCompilation (TypeSystemService.LoadAssemblyContext (runtime, targetFramework, file)); if (dom == null) throw new Exception ("System.Web parse database not found for framework " + targetFramework.Id + " file '" + file + "'"); return dom; }
protected override void Initialize (TargetRuntime runtime, TargetFramework framework) { base.Initialize (runtime, framework); fxVersion = GetFxVersion (framework); foreach (var dir in GetMoonDirectories ()) { var fxdir = dir.Combine (fxVersion); var buildVersion = fxdir.Combine ("buildversion"); if (Directory.Exists (fxdir) && Directory.Exists (fxdir + "-redist") && File.Exists (buildVersion)) { if (LoadVersionString (buildVersion) && RegisterRedistAssemblies (dir)) this.location = dir; break; } } }
protected override void Initialize (TargetRuntime runtime, TargetFramework framework) { if (framework.Id.Identifier != "Silverlight") throw new InvalidOperationException (string.Format ("Cannot handle unknown framework {0}", framework.Id)); base.Initialize (runtime, framework); fxVersion = framework.Id.Version; foreach (var dir in GetMoonDirectories ()) { var fxdir = dir.Combine (fxVersion); var buildVersion = fxdir.Combine ("buildversion"); if (Directory.Exists (fxdir) && Directory.Exists (fxdir + "-redist") && File.Exists (buildVersion)) { if (LoadVersionString (buildVersion) && RegisterRedistAssemblies (dir)) this.location = dir; break; } } }
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); }
internal static Framework Load (TargetFramework target, string path) { Framework fx = new Framework (target); 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; } } } return fx; }
/// <summary> /// Checks if a framework is installed in this runtime. /// </summary> /// <param name="fx"> /// The runtime to check. /// </param> /// <returns> /// True if the framework is installed /// </returns> public bool IsInstalled(TargetFramework fx) { return(GetBackend(fx).IsInstalled); }
// Given the full name of an assembly, returns the corresponding full assembly name // in the specified target CLR version, or null if it doesn't exist in that version. public SystemAssembly GetAssemblyForVersion (string fullName, string packageName, TargetFramework fx) { Initialize (); fullName = NormalizeAsmName (fullName); //get the SystemAssembly for the current fullname, NOT the new target fx //in order to be able to check whether it's a framework assembly SystemAssembly asm = GetAssemblyFromFullName (fullName, packageName, null); if (asm == null) return null; var fxAsms = asm.AllSameName ().Where (a => a.Package.IsFrameworkPackage); //if the asm is not a framework asm, we don't upgrade it automatically if (!fxAsms.Any ()) { // Return null if the package is not compatible with the requested version if (fx.IsCompatibleWithFramework (asm.Package.TargetFramework)) return asm; else return null; } foreach (var fxAsm in fxAsms) { if (fx.IsExtensionOfFramework (fxAsm.Package.TargetFramework)) return fxAsm; } // We have to find the assembly with the same name in the target fx string fname = Path.GetFileName ((string) fxAsms.First ().Location); foreach (var pair in assemblyFullNameToAsm) { foreach (var fxAsm in pair.Value.AllSameName ()) { var rpack = fxAsm.Package; if (rpack.IsFrameworkPackage && fx.IsExtensionOfFramework (rpack.TargetFramework) && Path.GetFileName (fxAsm.Location) == fname) return fxAsm; } } return null; }
public virtual bool SupportsFramework (TargetFramework framework) { if (LanguageBinding == null) return false; ClrVersion[] versions = LanguageBinding.GetSupportedClrVersions (); if (versions != null && versions.Length > 0 && framework != null) { foreach (ClrVersion v in versions) { if (v == framework.ClrVersion) return true; } } return false; }
public string GetAssemblyLocation (string assemblyName, TargetFramework fx) { return GetAssemblyLocation (assemblyName, null, fx); }
// Given the full name of an assembly, returns the corresponding full assembly name // in the specified target CLR version, or null if it doesn't exist in that version. public string GetAssemblyNameForVersion (string fullName, TargetFramework fx) { return GetAssemblyNameForVersion (fullName, null, fx); }
public override string GetMSBuildBinPath(TargetFramework fx) { return(Path.Combine(monoDir, "2.0")); }
internal protected virtual void Initialize(TargetRuntime runtime, TargetFramework framework) { this.runtime = runtime; this.framework = framework; }
protected virtual TargetFrameworkBackend CreateBackend(TargetFramework fx) { return(null); }
public override bool SupportsFramework(MonoDevelop.Core.Assemblies.TargetFramework framework) { return(framework.Id.Identifier == "Silverlight"); }
//FIXME: the fallback is broken since multiple frameworks can have the same corlib public TargetFrameworkMoniker GetTargetFrameworkForAssembly(TargetRuntime tr, string file) { if (!File.Exists(file)) { return(TargetFrameworkMoniker.UNKNOWN); } try { using (var reader = new PEReader(File.OpenRead(file))) { var mr = reader.GetMetadataReader(); foreach (var customAttributeHandle in mr.GetAssemblyDefinition().GetCustomAttributes()) { var customAttribute = mr.GetCustomAttribute(customAttributeHandle); var ctorHandle = customAttribute.Constructor; if (ctorHandle.Kind != HandleKind.MemberReference) { continue; } var ctor = mr.GetMemberReference((MemberReferenceHandle)ctorHandle); var attrType = mr.GetTypeReference((TypeReferenceHandle)ctor.Parent); var ns = mr.GetString(attrType.Namespace); if (ns != "System.Runtime.Versioning") { continue; } var typeName = mr.GetString(attrType.Name); if (typeName != "TargetFrameworkAttribute") { continue; } var provider = new StringParameterValueTypeProvider(mr, customAttribute.Value); var signature = ctor.DecodeMethodSignature(provider, null); var parameterTypes = signature.ParameterTypes; if (parameterTypes.Length != 1) { continue; } var value = parameterTypes [0]; if (value != null && TargetFrameworkMoniker.TryParse(value, out var m)) { return(m); } LoggingService.LogError("Invalid TargetFrameworkAttribute in assembly {0} - {1}", file, value); } if (tr != null) { foreach (var assemblyReferenceHandle in mr.AssemblyReferences) { var assemblyReference = mr.GetAssemblyReference(assemblyReferenceHandle); var name = mr.GetString(assemblyReference.Name); if (name != "mscorlib") { continue; } TargetFramework compatibleFramework = null; // If there are several frameworks that can run the file, pick one that is installed foreach (TargetFramework tf in GetKnownFrameworks()) { if (tf.GetCorlibVersion() == assemblyReference.Version.ToString()) { compatibleFramework = tf; if (tr.IsInstalled(tf)) { return(tf.Id); } } } if (compatibleFramework != null) { return(compatibleFramework.Id); } break; } } } } catch (Exception ex) { LoggingService.LogError("Error determining target framework for assembly {0}: {1}", file, ex); } return(TargetFrameworkMoniker.UNKNOWN); }
internal protected virtual IEnumerable <string> GetFrameworkFolders(TargetFramework fx) { return(GetBackend(fx).GetFrameworkFolders()); }
/// <summary> /// Returns a list of environment variables that should be set when running tools using this runtime /// </summary> public virtual ExecutionEnvironment GetToolsExecutionEnvironment(TargetFramework fx) { return(new ExecutionEnvironment(GetBackend(fx).GetToolsEnvironmentVariables())); }
/// <summary> /// Looks for the specified tool in this runtime. The name can be a script or a .exe. /// </summary> public virtual string GetToolPath(TargetFramework fx, string toolName) { return(GetBackend(fx).GetToolPath(toolName)); }
/// <summary> /// Returns a list of paths which can contain tools for this runtime. /// </summary> public virtual IEnumerable <string> GetToolsPaths(TargetFramework fx) { return(GetBackend(fx).GetToolsPaths()); }
/// <summary> /// Executes an assembly using this runtime and the specified framework. /// </summary> /// <param name="pinfo"> /// Information of the process to execute /// </param> /// <param name="fx"> /// Framework on which the assembly has to be executed. /// </param> /// <returns> /// The started process. /// </returns> public virtual Process ExecuteAssembly(ProcessStartInfo pinfo, TargetFramework fx) { ConvertAssemblyProcessStartInfo(pinfo); return(Process.Start(pinfo)); }
/// <summary> /// Returns the MSBuild bin path for this runtime. /// </summary> public abstract string GetMSBuildBinPath(TargetFramework fx);
public override string GetAssemblyLocation(string assemblyName, string package, TargetFramework fx) { string loc = base.GetAssemblyLocation(assemblyName, package, fx); if (loc != null) { return(loc); } string baseDirectory = AppDomain.CurrentDomain.BaseDirectory; string name; int i = assemblyName.IndexOf(','); if (i == -1) { name = assemblyName; } else { name = assemblyName.Substring(0, i).Trim(); } // Look in initial path if (!string.IsNullOrEmpty(baseDirectory)) { string localPath = Path.Combine(baseDirectory, name); if (File.Exists(localPath)) { return(localPath); } } // Look in assembly directories foreach (string path in GetAssemblyDirectories()) { string localPath = Path.Combine(path, name); if (File.Exists(localPath)) { return(localPath); } } // Look in the gac return(GetGacFile(assemblyName, true)); }
// Given the full name of an assembly, returns the corresponding full assembly name // in the specified target CLR version, or null if it doesn't exist in that version. public SystemAssembly GetAssemblyForVersion(string fullName, string packageName, TargetFramework fx) { Initialize(); fullName = NormalizeAsmName(fullName); //get the SystemAssembly for the current fullname, NOT the new target fx //in order to be able to check whether it's a framework assembly SystemAssembly asm = GetAssemblyFromFullName(fullName, packageName, null); if (asm == null) { return(null); } var fxAsms = asm.AllSameName().Where(a => a.Package.IsFrameworkPackage); //if the asm is not a framework asm, we don't upgrade it automatically if (!fxAsms.Any()) { // Return null if the package is not compatible with the requested version if (fx.IsCompatibleWithFramework(asm.Package.TargetFramework)) { return(asm); } else { return(null); } } foreach (var fxAsm in fxAsms) { if (fx.IncludesFramework(fxAsm.Package.TargetFramework)) { return(fxAsm); } } // We have to find the assembly with the same name in the target fx string fname = Path.GetFileName((string)fxAsms.First().Location); foreach (var pair in assemblyFullNameToAsm) { foreach (var fxAsm in pair.Value.AllSameName()) { var rpack = fxAsm.Package; if (rpack.IsFrameworkPackage && fx.IncludesFramework(rpack.TargetFramework) && Path.GetFileName(fxAsm.Location) == fname) { return(fxAsm); } } } return(null); }
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; //The concept of "ClrVersion" breaks down hard after 4.5 and is essentially meaningless default: fx.clrVersion = ClrVersion.Net_4_5; break; } } 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 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); }
// Given the full name of an assembly, returns the corresponding full assembly name // in the specified target CLR version, or null if it doesn't exist in that version. public string GetAssemblyNameForVersion(string fullName, TargetFramework fx) { return(GetAssemblyNameForVersion(fullName, null, fx)); }
// Returns the installed version of the given assembly name // (it returns the full name of the installed assembly). public string FindInstalledAssembly (string fullname, string package, TargetFramework fx) { Initialize (); fullname = NormalizeAsmName (fullname); SystemAssembly fasm = GetAssemblyFromFullName (fullname, package, fx); if (fasm != null) return fullname; // Try to find a newer version of the same assembly, preferring framework assemblies if (fx == null) { string best = null; foreach (SystemAssembly asm in FindNewerAssembliesSameName (fullname)) { if (package == null || asm.Package.Name == package) { if (asm.Package.IsFrameworkPackage) return asm.FullName; else best = asm.FullName; } } return best; } string bestMatch = null; foreach (SystemAssembly asm in FindNewerAssembliesSameName (fullname)) { if (asm.Package.IsFrameworkPackage) { if (fx.IsExtensionOfFramework (asm.Package.TargetFramework)) if (package == null || asm.Package.Name == package) return asm.FullName; } else if (fx.IsCompatibleWithFramework (asm.Package.TargetFramework)) { if (package != null && asm.Package.Name == package) return asm.FullName; bestMatch = asm.FullName; } } return bestMatch; }
public virtual string GetAssemblyLocation(string assemblyName, string package, TargetFramework fx) { Initialize(); assemblyName = NormalizeAsmName(assemblyName); SystemAssembly asm = GetAssemblyFromFullName(assemblyName, package, fx); if (asm != null) { return(asm.Location); } return(null); }
public virtual string GetAssemblyLocation (string assemblyName, string package, TargetFramework fx) { Initialize (); assemblyName = NormalizeAsmName (assemblyName); SystemAssembly asm = GetAssemblyFromFullName (assemblyName, package, fx); if (asm != null) return asm.Location; return null; }
public string GetAssemblyLocation(string assemblyName, TargetFramework fx) { return(GetAssemblyLocation(assemblyName, null, fx)); }
public string GetAssemblyNameForVersion (string fullName, string packageName, TargetFramework fx) { SystemAssembly asm = GetAssemblyForVersion (fullName, packageName, fx); if (asm != null) return asm.FullName; else return null; }
public SystemAssembly GetAssemblyFromFullName(string fullname, string package, TargetFramework fx) { if (package == null) { SystemAssembly found = null; SystemAssembly gacFound = null; foreach (SystemAssembly asm in GetAssembliesFromFullNameInternal(fullname)) { found = asm; if (asm.Package.IsFrameworkPackage && fx != null && fx.IncludesFramework(asm.Package.TargetFramework)) { return(asm); } if (asm.Package.IsGacPackage) { gacFound = asm; } } return(gacFound ?? found); } foreach (SystemAssembly asm in GetAssembliesFromFullNameInternal(fullname)) { if (package == asm.Package.Name) { return(asm); } } return(null); }
public string GetAssemblyFullName (string assemblyName, TargetFramework fx) { Initialize (); assemblyName = NormalizeAsmName (assemblyName); // Fast path for known assemblies. if (assemblyFullNameToAsm.ContainsKey (assemblyName)) return assemblyName; // Look in assemblies of the framework. Done here since later steps look in the gac // without taking into account the framework. foreach (SystemAssembly sa in GetAssemblies (fx)) { if (sa.Package.IsGacPackage && sa.Name == assemblyName) return sa.FullName; } if (File.Exists (assemblyName)) return SystemAssemblyService.GetAssemblyName (assemblyName); string file = GetAssemblyLocation (assemblyName, fx); if (file != null) return SystemAssemblyService.GetAssemblyName (file); else return null; }
protected override TargetFrameworkBackend CreateBackend(TargetFramework fx) { return(new MonoFrameworkBackend()); }
protected internal override void OnSave (IProgressMonitor monitor) { // Make sure the fx version is sorted out before saving // to avoid changes in project references while saving if (targetFramework == null) targetFramework = Runtime.SystemAssemblyService.GetTargetFramework (GetDefaultTargetFrameworkForFormat (FileFormat)); base.OnSave (monitor); }
protected virtual SystemPackageInfo GetFrameworkPackageInfo(TargetFramework fx, string packageName) { return(GetBackend(fx).GetFrameworkPackageInfo(packageName)); }
public void SetTargetFramework (IAssemblyContext targetContext, TargetFramework targetVersion) { this.targetContext = targetContext; this.targetVersion = targetVersion; }
//FIXME: the fallback is broken since multiple frameworks can have the same corlib public TargetFrameworkMoniker GetTargetFrameworkForAssembly(TargetRuntime tr, string file) { if (!File.Exists(file)) { return(TargetFrameworkMoniker.UNKNOWN); } AssemblyDefinition assembly = null; try { assembly = AssemblyDefinition.ReadAssembly(file); var att = assembly.CustomAttributes.FirstOrDefault(a => a.AttributeType.FullName == "System.Runtime.Versioning.TargetFrameworkAttribute" ); if (att != null) { if (att.ConstructorArguments.Count == 1) { var v = att.ConstructorArguments[0].Value as string; TargetFrameworkMoniker m; if (v != null && TargetFrameworkMoniker.TryParse(v, out m)) { return(m); } } LoggingService.LogError("Invalid TargetFrameworkAttribute in assembly {0}", file); } if (tr != null) { foreach (var r in assembly.MainModule.AssemblyReferences) { if (r.Name == "mscorlib") { TargetFramework compatibleFramework = null; // If there are several frameworks that can run the file, pick one that is installed foreach (TargetFramework tf in GetKnownFrameworks()) { if (tf.GetCorlibVersion() == r.Version.ToString()) { compatibleFramework = tf; if (tr.IsInstalled(tf)) { return(tf.Id); } } } if (compatibleFramework != null) { return(compatibleFramework.Id); } break; } } } } catch (Exception ex) { LoggingService.LogError("Error determining target framework for assembly {0}: {1}", file, ex); return(TargetFrameworkMoniker.UNKNOWN); } finally { assembly?.Dispose(); } LoggingService.LogError("Failed to determine target framework for assembly {0}", file); return(TargetFrameworkMoniker.UNKNOWN); }