Jelajahi Sumber

[xbuild] / [PCL]: Report an error for unsupported / missing PCL Profiles.

We previously only reported a warning, then failed later with tons of
"The predefined type `System.Object' is not defined or imported", which
was very confusing to the user.

We now distinguish between missing Reference Assemblies (ie. none of
them are installed) and the requested profile not being available, reporting
a meaningful error message.
Martin Baulig 12 tahun lalu
induk
melakukan
ffe8719327

+ 13 - 0
mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/GetReferenceAssemblyPaths.cs

@@ -60,6 +60,8 @@ namespace Microsoft.Build.Tasks
 				Log.LogWarning ("Unable to find framework corresponding to the target framework moniker '{0}'. " +
 						"Framework assembly references will be resolved from the GAC, which might not be " +
 						"the intended behavior.", TargetFrameworkMoniker);
+				if (moniker.Identifier.Equals (".NETPortable"))
+					return CheckPclReferenceAssemblies (moniker);
 				return true;
 			}
 
@@ -69,6 +71,17 @@ namespace Microsoft.Build.Tasks
 			return true;
 		}
 
+		bool CheckPclReferenceAssemblies (FrameworkMoniker moniker)
+		{
+			// Check for a supported profile
+			var check = new FrameworkMoniker (".NETPortable", "v4.0", "Profile24");
+			if (GetFrameworkDirectoriesForMoniker (check) != null)
+				Log.LogError ("Unsupported PCL Profile '{0}'.", moniker);
+			else
+				Log.LogError ("PCL Reference Assemblies not installed.");
+			return false;
+		}
+
 		Framework GetFrameworkDirectoriesForMoniker (FrameworkMoniker moniker)
 		{
 			string dirs = String.Join (PathSeparatorAsString, new string [] {