Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -315,7 +315,7 @@ namespace Microsoft.Build.BuildEngine {
return;
}
}
DirectoryScanner directoryScanner;
Expression includeExpr, excludeExpr;
ITaskItem[] includes, excludes;
@@ -341,8 +341,10 @@ namespace Microsoft.Build.BuildEngine {
directoryScanner.Includes = includes;
directoryScanner.Excludes = excludes;
if (project.FullFileName != String.Empty)
if (project.FullFileName != String.Empty) {
directoryScanner.ProjectFile = project.ThisFileFullPath;
directoryScanner.BaseDirectory = new DirectoryInfo (Path.GetDirectoryName (project.FullFileName));
}
else
directoryScanner.BaseDirectory = new DirectoryInfo (Directory.GetCurrentDirectory ());

View File

@@ -42,16 +42,19 @@ namespace Microsoft.Build.BuildEngine {
if (whenElement == null)
throw new ArgumentNullException ("whenElement");
this.whenElement = whenElement;
foreach (XmlElement xe in whenElement.ChildNodes) {
switch (xe.Name) {
foreach (XmlNode node in whenElement.ChildNodes) {
switch (node.NodeType) {
case XmlNodeType.Element:
var xe = (XmlElement)node;
switch (xe.Name) {
case "ItemGroup":
BuildItemGroup big = new BuildItemGroup (xe, parentProject, null, true);
//big.BindToXml (xe);
//big.BindToXml (xe);
groupingCollection.Add (big);
break;
case "PropertyGroup":
BuildPropertyGroup bpg = new BuildPropertyGroup (xe, parentProject, null, true);
//bpg.BindToXml (xe);
//bpg.BindToXml (xe);
groupingCollection.Add (bpg);
break;
case "Choose":
@@ -59,7 +62,13 @@ namespace Microsoft.Build.BuildEngine {
groupingCollection.Add (bc);
break;
default:
throw new InvalidProjectFileException ( string.Format ("Invalid element '{0}' in When.", xe.Name));
throw new InvalidProjectFileException (string.Format ("Invalid element '{0}' in When.", xe.Name));
}
break;
case XmlNodeType.Comment:
break;
default:
throw new InvalidProjectFileException (string.Format ("Invalid element '{0}' in When Condition.", node.NodeType));
}
}
}

View File

@@ -291,11 +291,7 @@ namespace Microsoft.Build.BuildEngine
// Hence we expect sender as a valid object only if it is IBuildEngine4 -
// only Microsoft.Build.Internal.BuildEngine4 implements it so far.
// (Used IBuildEngine3 because it needs to build for NET_4_0).
#if NET_4_0
var key = sender as IBuildEngine3 ?? dummy_key;
#else
var key = dummy_key;
#endif
if (!build_records.TryGetValue (key, out r)) {
r = new BuildRecord (this);
build_records.Add (key, r);

View File

@@ -38,6 +38,7 @@ namespace Microsoft.Build.BuildEngine {
DirectoryInfo baseDirectory;
ITaskItem[] includes, excludes;
ITaskItem[] matchedItems;
string projectFile;
static bool _runningOnWindows;
@@ -82,8 +83,11 @@ namespace Microsoft.Build.BuildEngine {
string name = include_item.ItemSpec;
if (!HasWildcard (name)) {
if (!excludedItems.ContainsKey (Path.GetFullPath(name)))
if (!excludedItems.ContainsKey (Path.GetFullPath (name))) {
includedItems.Add (include_item);
if (projectFile != null)
include_item.SetMetadata ("DefiningProjectFullPath", projectFile);
}
} else {
if (name.Split (Path.DirectorySeparatorChar).Length > name.Split (Path.AltDirectorySeparatorChar).Length) {
separatedPath = name.Split (new char [] {Path.DirectorySeparatorChar},
@@ -127,6 +131,8 @@ namespace Microsoft.Build.BuildEngine {
rec_dir += Path.DirectorySeparatorChar;
item.SetMetadata ("RecursiveDir", rec_dir);
}
if (projectFile != null)
item.SetMetadata ("DefiningProjectFullPath", projectFile);
includedItems.Add (item);
}
}
@@ -236,6 +242,11 @@ namespace Microsoft.Build.BuildEngine {
set { baseDirectory = value; }
}
public string ProjectFile {
get { return projectFile; }
set { projectFile = value; }
}
public ITaskItem[] Includes {
get { return includes; }
set { includes = value; }

View File

@@ -110,16 +110,12 @@ namespace Microsoft.Build.BuildEngine {
{
Toolsets.Add (new Toolset ("2.0",
ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version20)));
#if NET_3_5
Toolsets.Add (new Toolset ("3.0",
ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version30)));
Toolsets.Add (new Toolset ("3.5",
ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version35)));
#endif
#if NET_4_0
Toolsets.Add (new Toolset ("4.0",
ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version40)));
#endif
#if XBUILD_12
Toolsets.Add (new Toolset ("12.0", ToolLocationHelper.GetPathToBuildTools ("12.0")));
#endif
@@ -560,11 +556,9 @@ namespace Microsoft.Build.BuildEngine {
get {
// This is used as the fall back version if the
// project can't find a version to use
// Hard-coded to 2.0, so it allows even vs2005 projects
// to build correctly, as they won't have a ToolsVersion
// set!
return String.IsNullOrEmpty (defaultToolsVersion)
? "2.0"
?
"4.0"
: defaultToolsVersion;
}
set {

View File

@@ -152,6 +152,15 @@ namespace Microsoft.Build.BuildEngine {
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))
@@ -231,7 +240,6 @@ namespace Microsoft.Build.BuildEngine {
if (String.IsNullOrEmpty (parsed_import))
throw new InvalidProjectFileException ("The required attribute \"Project\" in Import is empty");
#if NET_4_0
if (DirectoryScanner.HasWildcard (parsed_import)) {
var directoryScanner = new DirectoryScanner () {
Includes = new ITaskItem [] { new TaskItem (parsed_import) },
@@ -242,7 +250,6 @@ namespace Microsoft.Build.BuildEngine {
foreach (ITaskItem matchedItem in directoryScanner.MatchedItems)
yield return matchedItem.ItemSpec;
} else
#endif
yield return parsed_import;
}

View File

@@ -27,6 +27,7 @@
//
using System;
using System.IO;
using Mono.XBuild.Utilities;
namespace Microsoft.Build.BuildEngine
@@ -121,7 +122,20 @@ namespace Microsoft.Build.BuildEngine
public static string GetDirectoryNameOfFileAbove (string path, string file)
{
throw new NotImplementedException ("GetDirectoryNameOfFileAbove");
string filePath;
path = Path.GetFullPath (path);
while (true) {
filePath = Path.Combine (path, file);
if (File.Exists (filePath))
return path;
path = Path.GetDirectoryName (path);
if (path == null) // we traversed up until root without a match, return empty string
return "";
}
}
public static object GetRegistryValue (string key, string value)
@@ -136,7 +150,18 @@ namespace Microsoft.Build.BuildEngine
public static string MakeRelative (string basePath, string path)
{
throw new NotImplementedException ("MakeRelative");
if (String.IsNullOrEmpty (basePath))
return path;
// ensure trailing slash for basePath
if (basePath [basePath.Length - 1] != '\\' && basePath [basePath.Length - 1] != '/')
basePath += '/';
var uriBasePath = new Uri (basePath, UriKind.Absolute);
var uriPath = new Uri (path);
var uriRelative = uriBasePath.MakeRelativeUri (uriPath);
return Uri.UnescapeDataString (uriRelative.ToString ()).Replace ('/', '\\'); // msbuild uses backslash paths everywhere
}
public static string ValueOrDefault (string value, string defaultValue)
@@ -144,4 +169,4 @@ namespace Microsoft.Build.BuildEngine
return string.IsNullOrEmpty (value) ? defaultValue : value;
}
}
}
}

View File

@@ -323,9 +323,7 @@ namespace Microsoft.Build.BuildEngine {
Reevaluate ();
}
#if NET_4_0
ProcessBeforeAndAfterTargets ();
#endif
if (targetNames == null || targetNames.Length == 0) {
if (defaultTargets != null && defaultTargets.Length != 0) {
@@ -404,7 +402,6 @@ namespace Microsoft.Build.BuildEngine {
return sb.ToString ();
}
#if NET_4_0
void ProcessBeforeAndAfterTargets ()
{
var beforeTable = Targets.AsIEnumerable ()
@@ -440,7 +437,6 @@ namespace Microsoft.Build.BuildEngine {
expr.Parse (targets, ParseOptions.AllowItemsNoMetadataAndSplit);
return (string []) expr.ConvertTo (this, typeof (string []));
}
#endif
[MonoTODO]
public string [] GetConditionedPropertyValues (string propertyName)
@@ -1429,6 +1425,10 @@ namespace Microsoft.Build.BuildEngine {
return default (T);
}
internal string ThisFileFullPath {
get { return this_file_property_stack.Peek (); }
}
// Used for MSBuild*This* set of properties
internal void PushThisFileProperty (string full_filename)
{

View File

@@ -77,7 +77,6 @@ namespace Microsoft.Build.BuildEngine {
} else if (onErrorFound)
throw new InvalidProjectFileException (
"The element <OnError> must be last under element <Target>. Found element <Error> instead.");
#if NET_3_5
else if (xe.Name == "ItemGroup") {
var group = new BuildTaskItemGroup (xe, this);
buildTasks.AddRange (group.Items);
@@ -86,7 +85,6 @@ namespace Microsoft.Build.BuildEngine {
buildTasks.Add (new BuildTaskPropertyGroup (xe, this));
continue;
}
#endif
else
buildTasks.Add (new BuildTask (xe, this));
}
@@ -176,14 +174,10 @@ namespace Microsoft.Build.BuildEngine {
try {
buildState = BuildState.Started;
#if NET_4_0
result = BuildDependencies (out executeOnErrors) &&
BuildBeforeThisTargets (out executeOnErrors) &&
DoBuild (out executeOnErrors) && // deps & Before targets built fine, do main build
BuildAfterThisTargets (out executeOnErrors);
#else
result = BuildDependencies (out executeOnErrors) && DoBuild (out executeOnErrors);
#endif
buildState = BuildState.Finished;
} catch (Exception e) {
@@ -224,7 +218,6 @@ namespace Microsoft.Build.BuildEngine {
return result;
}
#if NET_4_0
bool BuildBeforeThisTargets (out bool executeOnErrors)
{
executeOnErrors = false;
@@ -246,7 +239,6 @@ namespace Microsoft.Build.BuildEngine {
return result;
}
#endif
bool BuildOtherTargets (IEnumerable<string> targetNames, Action<string> missing_target, out bool executeOnErrors)
{
@@ -379,7 +371,6 @@ namespace Microsoft.Build.BuildEngine {
}
}
#if NET_4_0
internal string BeforeTargets {
get { return targetElement.GetAttribute ("BeforeTargets"); }
}
@@ -390,7 +381,6 @@ namespace Microsoft.Build.BuildEngine {
internal List<string> BeforeThisTargets { get; set; }
internal List<string> AfterThisTargets { get; set; }
#endif
internal List<IBuildTask> BuildTasks {
get { return buildTasks; }