diff options
3 files changed, 41 insertions, 2 deletions
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpBindingCompilerManager.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpBindingCompilerManager.cs index 50367e1422..2cacafd70f 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpBindingCompilerManager.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/CSharpBindingCompilerManager.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Diagnostics; using System.Text.RegularExpressions; using System.Text; @@ -159,7 +160,14 @@ namespace MonoDevelop.CSharp } } } - + + if (alreadyAddedReference.Any (reference => SystemAssemblyService.ContainsReferenceToSystemRuntime (reference))) { + LoggingService.LogInfo ("Found PCLv2 assembly."); + var facades = runtime.FindFacadeAssembliesForPCL (project.TargetFramework); + foreach (var facade in facades) + AppendQuoted (sb, "/r:", facade); + } + string sysCore = project.AssemblyContext.GetAssemblyFullName ("System.Core", project.TargetFramework); if (sysCore != null) { sysCore = project.AssemblyContext.GetAssemblyLocation (sysCore, project.TargetFramework); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/SystemAssemblyService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/SystemAssemblyService.cs index f9eb156bb7..d757ed1ba7 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/SystemAssemblyService.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/SystemAssemblyService.cs @@ -391,6 +391,24 @@ namespace MonoDevelop.Core.Assemblies } } + public static bool ContainsReferenceToSystemRuntime (string fileName) + { + using (var universe = new IKVM.Reflection.Universe ()) { + IKVM.Reflection.Assembly assembly; + try { + assembly = universe.LoadFile (fileName); + } catch { + return false; + } + foreach (var r in assembly.GetReferencedAssemblies ()) { + if (r.FullName.Equals ("System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")) + return true; + } + } + + return false; + } + public class ManifestResource { public string Name { diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs index b29e6b028b..04225123bb 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs @@ -281,7 +281,20 @@ namespace MonoDevelop.Core.Assemblies { return GetBackend (fx).GetFrameworkFolders (); } - + + public IEnumerable<string> FindFacadeAssembliesForPCL (TargetFramework tx) + { + foreach (var folder in GetFrameworkFolders (tx)) { + var facades = Path.Combine (folder, "Facades"); + if (!Directory.Exists (facades)) + continue; + + return Directory.GetFiles (facades, "*.dll"); + } + + return null; + } + /// <summary> /// Returns a list of environment variables that should be set when running tools using this runtime /// </summary> |