Merge pull request #3028 from lateralusX/jlorenss/threadpool_warning
[mono.git] / mcs / class / Microsoft.Build.Tasks / Microsoft.Build.Tasks / ResolveAssemblyReference.cs
index 5a40c8e0c1ec4bdcec506fc628d05fde656eee88..3bdf7111df8b3295f5f37cd50d92238d846128e5 100644 (file)
@@ -128,6 +128,10 @@ namespace Microsoft.Build.Tasks {
                        relatedFiles = tempRelatedFiles.Values.ToArray ();
                        resolvedDependencyFiles = tempResolvedDepFiles.Values.ToArray ();
 
+#if XBUILD_14
+                       DependsOnSystemRuntime = resolvedDependencyFiles.Any (x => Path.GetFileName (x.ItemSpec) == "System.Runtime.dll").ToString ();
+#endif
+
                        tempResolvedFiles.Clear ();
                        tempCopyLocalFiles.Clear ();
                        tempSatelliteFiles.Clear ();
@@ -208,9 +212,36 @@ namespace Microsoft.Build.Tasks {
                        if (!TryGetSpecificVersionValue (item, out specific_version))
                                return null;
 
+                       var spath_index  = 0;
                        foreach (string spath in search_paths) {
+                               if (string.IsNullOrEmpty (spath))
+                                       continue;
                                assembly_resolver.LogSearchMessage ("For searchpath {0}", spath);
 
+                               // The first value of search_paths can be the parent assembly directory.
+                               // In that case the value would be treated as a directory.
+                               // This code checks if we should treat the value as a TargetFramework assembly.
+                               // Doing so avoids CopyLocal beeing set to true.
+                               if (spath_index++ == 0 && targetFrameworkDirectories != null) {
+                                       foreach (string fpath in targetFrameworkDirectories) {
+                                               if (string.IsNullOrEmpty (fpath))
+                                                       continue;
+                                               if (String.Compare (
+                                                               Path.GetFullPath (spath).TrimEnd (Path.DirectorySeparatorChar),
+                                                               Path.GetFullPath (fpath).TrimEnd (Path.DirectorySeparatorChar),
+                                                               StringComparison.InvariantCulture) != 0)
+                                                       continue;
+
+                                               resolved = assembly_resolver.FindInTargetFramework (item,
+                                                       fpath, specific_version);
+
+                                               break;
+                                       }
+
+                                       if  (resolved != null)
+                                               break;
+                               }
+
                                if (String.Compare (spath, "{HintPathFromItem}") == 0) {
                                        resolved = assembly_resolver.ResolveHintPathReference (item, specific_version);
                                } else if (String.Compare (spath, "{TargetFrameworkDirectory}") == 0) {
@@ -599,6 +630,13 @@ namespace Microsoft.Build.Tasks {
                public ITaskItem[] CopyLocalFiles {
                        get { return copyLocalFiles; }
                }
+
+#if XBUILD_14
+               [Output]
+               public string DependsOnSystemRuntime {
+                       get; private set;
+               }
+#endif
                
                [Output]
                public ITaskItem[] FilesWritten {
@@ -627,11 +665,7 @@ namespace Microsoft.Build.Tasks {
                }
 
                public
-#if NET_4_0
                ITaskItem[]
-#else
-               string[]
-#endif
                InstalledAssemblyTables { get; set; }
 
                [Output]
@@ -685,11 +719,9 @@ namespace Microsoft.Build.Tasks {
                        get { return suggestedRedirects; }
                }
 
-#if NET_4_0
                public string TargetFrameworkMoniker { get; set; }
 
                public string TargetFrameworkMonikerDisplayName { get; set; }
-#endif
 
                public string TargetFrameworkVersion { get; set; }