Imported Upstream version 3.8.0

Former-commit-id: 6a76a29bd07d86e57c6c8da45c65ed5447d38a61
This commit is contained in:
Jo Shields
2014-09-04 09:07:35 +01:00
parent a575963da9
commit fe777c5c82
1062 changed files with 12460 additions and 5983 deletions

View File

@@ -37,6 +37,7 @@ using Microsoft.Build.Exceptions;
using System.Globalization;
using Microsoft.Build.Construction;
using Microsoft.Build.Internal.Expressions;
using System.Xml;
namespace Microsoft.Build.Internal
{
@@ -121,17 +122,23 @@ namespace Microsoft.Build.Internal
try {
var initialPropertiesFormatted = "Initial Properties:\n" + string.Join (Environment.NewLine, project.Properties.OrderBy (p => p.Name).Select (p => string.Format ("{0} = {1}", p.Name, p.EvaluatedValue)).ToArray ());
LogMessageEvent (new BuildMessageEventArgs (initialPropertiesFormatted, null, null, MessageImportance.Low));
var initialGlobalPropertiesFormatted = "Initial Global Properties:\n" + string.Join (Environment.NewLine, project.Properties.OrderBy (p => p.Name).Where (p => p.IsImmutable).Select (p => string.Format ("{0} = {1}", p.Name, p.EvaluatedValue)).ToArray ());
LogMessageEvent (new BuildMessageEventArgs (initialGlobalPropertiesFormatted, null, null, MessageImportance.Low));
var initialProjectPropertiesFormatted = "Initial Project Properties:\n" + string.Join (Environment.NewLine, project.Properties.OrderBy (p => p.Name).Where (p => !p.IsImmutable).Select (p => string.Format ("{0} = {1}", p.Name, p.EvaluatedValue)).ToArray ());
LogMessageEvent (new BuildMessageEventArgs (initialProjectPropertiesFormatted, null, null, MessageImportance.Low));
var initialItemsFormatted = "Initial Items:\n" + string.Join (Environment.NewLine, project.Items.OrderBy (i => i.ItemType).Select (i => string.Format ("{0} : {1}", i.ItemType, i.EvaluatedInclude)).ToArray ());
LogMessageEvent (new BuildMessageEventArgs (initialItemsFormatted, null, null, MessageImportance.Low));
// null targets -> success. empty targets -> success(!)
foreach (var targetName in (request.ProjectInstance.InitialTargets).Where (t => t != null))
BuildTargetByName (targetName, args);
if (request.TargetNames == null)
args.Result.OverallResult = BuildResultCode.Success;
args.Result.OverallResult = args.CheckCancel () ? BuildResultCode.Failure : args.Result.ResultsByTarget.Any (p => p.Value.ResultCode == TargetResultCode.Failure) ? BuildResultCode.Failure : BuildResultCode.Success;
else {
foreach (var targetName in (args.TargetNames ?? request.TargetNames).Where (t => t != null))
BuildTargetByName (targetName, args);
foreach (var targetName in (args.TargetNames ?? request.TargetNames).Where (t => t != null)) {
if (!BuildTargetByName (targetName, args))
break;
}
// FIXME: check .NET behavior, whether cancellation always results in failure.
args.Result.OverallResult = args.CheckCancel () ? BuildResultCode.Failure : args.Result.ResultsByTarget.Any (p => p.Value.ResultCode == TargetResultCode.Failure) ? BuildResultCode.Failure : BuildResultCode.Success;
@@ -253,6 +260,7 @@ namespace Microsoft.Build.Internal
var value = args.Project.ExpandString (p.Value);
project.SetProperty (p.Name, value);
}
continue;
}
var ii = child as ProjectItemGroupTaskInstance;
@@ -264,6 +272,7 @@ namespace Microsoft.Build.Internal
continue;
project.AddItem (item.ItemType, project.ExpandString (item.Include));
}
continue;
}
var task = child as ProjectTaskInstance;
@@ -275,7 +284,14 @@ namespace Microsoft.Build.Internal
}
if (!RunBuildTask (target, task, targetResult, args))
return false;
continue;
}
var onError = child as ProjectOnErrorInstance;
if (onError != null)
continue; // evaluated under catch clause.
throw new NotSupportedException (string.Format ("Unexpected Target element children \"{0}\"", child.GetType ()));
}
} catch (Exception ex) {
// fallback task specified by OnError element
@@ -452,7 +468,7 @@ namespace Microsoft.Build.Internal
}
public void SetMetadataValueLiteral (string metadataName, string metadataValue)
{
metadata [metadataName] = ProjectCollection.Unescape (metadataValue);
metadata [metadataName] = WindowsCompatibilityExtensions.NormalizeFilePath (ProjectCollection.Unescape (metadataValue));
}
public IDictionary CloneCustomMetadataEscaped ()
{
@@ -490,7 +506,7 @@ namespace Microsoft.Build.Internal
}
public void SetMetadata (string metadataName, string metadataValue)
{
metadata [metadataName] = metadataValue;
metadata [metadataName] = WindowsCompatibilityExtensions.NormalizeFilePath (metadataValue);
}
public string ItemSpec { get; set; }
public int MetadataCount {
@@ -574,13 +590,16 @@ namespace Microsoft.Build.Internal
// To NOT reuse this IBuildEngine instance for different build, we create another BuildManager and BuildSubmisson and then run it.
public bool BuildProjectFile (string projectFileName, string[] targetNames, IDictionary globalProperties, IDictionary targetOutputs, string toolsVersion)
{
toolsVersion = string.IsNullOrEmpty (toolsVersion) ? project.ToolsVersion : toolsVersion;
var globalPropertiesThatMakeSense = new Dictionary<string,string> ();
foreach (DictionaryEntry p in globalProperties)
globalPropertiesThatMakeSense [(string) p.Key] = (string) p.Value;
var result = new BuildManager ().Build (this.submission.BuildManager.OngoingBuildParameters.Clone (), new BuildRequestData (projectFileName, globalPropertiesThatMakeSense, toolsVersion, targetNames, null));
foreach (var p in result.ResultsByTarget)
targetOutputs [p.Key] = p.Value.Items;
return result.OverallResult == BuildResultCode.Success;
var projectToBuild = new ProjectInstance (ProjectRootElement.Create (XmlReader.Create (projectFileName)), globalPropertiesThatMakeSense, toolsVersion, Projects);
IDictionary<string,TargetResult> outs;
var ret = projectToBuild.Build (targetNames ?? new string [] {"Build"}, Projects.Loggers, out outs);
foreach (var p in outs)
targetOutputs [p.Key] = p.Value.Items ?? new ITaskItem [0];
return ret;
}
public bool BuildProjectFilesInParallel (string[] projectFileNames, string[] targetNames, IDictionary[] globalProperties, IDictionary[] targetOutputsPerProject, string[] toolsVersion, bool useResultsCache, bool unloadProjectsOnCompletion)