Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtsushi Eno <atsushieno@veritas-vos-liberabit.com>2013-01-11 15:43:53 +0400
committerAtsushi Eno <atsushieno@veritas-vos-liberabit.com>2013-01-11 15:44:17 +0400
commit2baeee2f8be0c629bd33dc503dfed432bd30047e (patch)
treed5f52e8d6e5efe1f592b01162acbc2fdba9d56a9
parent796fb86803afb741d22a0b0300a56894f5655f4c (diff)
[msbuild] Fix import set to expected path when invalid imports are allowed.mono-2.10.11
It was failing to resolve <Import> to correct path because it allowed invalid imports too early in Import.ForEachExtensionPathTillFound(). It is due to Project.AddSingleImport() that checks if invalid imports can be ignored by load setting. But simply removing this check results in regressions in nunit tests that fails to report required invalid imports. This bug was one of the blockers to build fsharp-droid from xbuild: https://github.com/fahadsuhaib/fsharp-droid
-rw-r--r--mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Import.cs59
-rw-r--r--mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs7
2 files changed, 38 insertions, 28 deletions
diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Import.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Import.cs
index 79893411b88..3b4ae86f0d8 100644
--- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Import.cs
+++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Import.cs
@@ -163,40 +163,45 @@ namespace Microsoft.Build.BuildEngine {
IEnumerable<string> extn_paths = has_extn_ref ? GetExtensionPaths (project) : new string [] {null};
bool import_needed = false;
+ var currentLoadSettings = project.ProjectLoadSettings;
try {
- foreach (string path in extn_paths) {
- string extn_msg = null;
- if (has_extn_ref) {
- project.SetExtensionsPathProperties (path);
- extn_msg = "from extension path " + path;
- }
+ foreach (var settings in new ProjectLoadSettings [] { ProjectLoadSettings.None, currentLoadSettings}) {
+ foreach (string path in extn_paths) {
+ string extn_msg = null;
+ if (has_extn_ref) {
+ project.SetExtensionsPathProperties (path);
+ extn_msg = "from extension path " + path;
+ }
- // do this after setting new Extension properties, as condition might
- // reference it
- if (!ConditionParser.ParseAndEvaluate (condition_attribute, project))
- continue;
-
- import_needed = true;
-
- // We stop if atleast one file got imported.
- // Remaining extension paths are *not* tried
- bool atleast_one = false;
- foreach (string importPath in GetImportPathsFromString (project_attribute, project, base_dir_info)) {
- try {
- if (func (importPath, extn_msg))
- atleast_one = true;
- } catch (Exception e) {
- throw new InvalidProjectFileException (String.Format (
- "{0}: Project file could not be imported, it was being imported by " +
- "{1}: {2}", importPath, importingFile, e.Message), e);
+ // do this after setting new Extension properties, as condition might
+ // reference it
+ if (!ConditionParser.ParseAndEvaluate (condition_attribute, project))
+ continue;
+
+ import_needed = true;
+ project.ProjectLoadSettings = settings;
+
+ // We stop if atleast one file got imported.
+ // Remaining extension paths are *not* tried
+ bool atleast_one = false;
+ foreach (string importPath in GetImportPathsFromString (project_attribute, project, base_dir_info)) {
+ try {
+ if (func (importPath, extn_msg))
+ atleast_one = true;
+ } catch (Exception e) {
+ throw new InvalidProjectFileException (String.Format (
+ "{0}: Project file could not be imported, it was being imported by " +
+ "{1}: {2}", importPath, importingFile, e.Message), e);
+ }
}
- }
- if (atleast_one)
- return;
+ if (atleast_one)
+ return;
+ }
}
} finally {
+ project.ProjectLoadSettings = currentLoadSettings;
if (has_extn_ref)
project.SetExtensionsPathProperties (Project.DefaultExtensionsPath);
}
diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs
index 3ef00f121d3..4c9bf0a8e56 100644
--- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs
+++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs
@@ -1560,7 +1560,7 @@ namespace Microsoft.Build.BuildEngine {
return xmlDocument != null && xmlDocument.DocumentElement.HasAttribute ("ToolsVersion");
}
}
-
+
public string ToolsVersion {
get; internal set;
}
@@ -1569,6 +1569,11 @@ namespace Microsoft.Build.BuildEngine {
get { return last_item_group_containing; }
}
+ internal ProjectLoadSettings ProjectLoadSettings {
+ get { return project_load_settings; }
+ set { project_load_settings = value; }
+ }
+
internal static XmlNamespaceManager XmlNamespaceManager {
get {
if (manager == null) {