project_attribute.IndexOf ("$(MSBuildExtensionsPath32)") >= 0 ||
project_attribute.IndexOf ("$(MSBuildExtensionsPath64)") >= 0;
+ bool condn_has_extn_ref = condition_attribute.IndexOf ("$(MSBuildExtensionsPath)") >= 0 ||
+ condition_attribute.IndexOf ("$(MSBuildExtensionsPath32)") >= 0 ||
+ condition_attribute.IndexOf ("$(MSBuildExtensionsPath64)") >= 0;
+
+ // we can skip the following logic in case the condition doesn't reference any extension paths
+ // and it evaluates to false since nothing would change anyway
+ if (!condn_has_extn_ref && !ConditionParser.ParseAndEvaluate (condition_attribute, project))
+ return;
+
string importingFile = importingProject != null ? importingProject.FullFileName : project.FullFileName;
DirectoryInfo base_dir_info = null;
if (!String.IsNullOrEmpty (importingFile))
project.LoadXml (documentString);
}
-#if NET_4_0
+ [Test]
+ public void TestImportEmptyVariableWithConditionFalse ()
+ {
+ string documentString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
+ <Import Project='$(ImportPath)' Condition='false' />
+ <Target Name='Build' />
+ </Project>";
+
+ engine = new Engine (Consts.BinPath);
+
+ project = engine.CreateNewProject ();
+ project.LoadXml (documentString);
+
+ Assert.IsTrue (project.Build ("Build"), "Build failed");
+ }
+
+ [Test]
+ public void TestImportProjectWithConditionReferencingExtensionPath ()
+ {
+ string documentString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
+ <Import Project='$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets' Condition=""Exists('$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets')"" />
+ <Target Name='Build' />
+ </Project>";
+
+ engine = new Engine (Consts.BinPath);
+
+ project = engine.CreateNewProject ();
+ project.LoadXml (documentString);
+
+ Assert.IsTrue (project.Build ("Build"), "Build failed");
+ }
+
[Test]
public void TestImportWildcard ()
{
File.Delete (second_project);
}
}
-#endif
}
}