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
path: root/mcs/class
diff options
context:
space:
mode:
authorAnkit Jain <radical@corewars.org>2010-06-22 21:24:16 +0400
committerAnkit Jain <radical@corewars.org>2010-06-22 21:24:16 +0400
commitc4b7ded3476ca09333f16b9c1378f1b84c440c22 (patch)
tree0a3109ee88274bf84a13534eb1759e127074e633 /mcs/class
parent9678267eb6999dda69d976dd0f533fdc8e8ac1c2 (diff)
Update xbuild and Microsoft.Build.* from trunk, with the
toolsversion support. svn path=/branches/mono-2-6/mcs/; revision=159362
Diffstat (limited to 'mcs/class')
-rw-r--r--mcs/class/Microsoft.Build.Engine/ChangeLog17
-rw-r--r--mcs/class/Microsoft.Build.Engine/Makefile41
-rw-r--r--mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildEngine.cs44
-rw-r--r--mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildTask.cs22
-rw-r--r--mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog82
-rw-r--r--mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConsoleLogger.cs69
-rw-r--r--mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/DirectoryScanner.cs10
-rw-r--r--mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs171
-rw-r--r--mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Import.cs49
-rw-r--r--mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/LogExtensions.cs183
-rw-r--r--mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs79
-rw-r--r--mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TargetBatchingImpl.cs71
-rw-r--r--mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TaskEngine.cs6
-rw-r--r--mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Toolset.cs53
-rw-r--r--mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ToolsetCollection.cs99
-rw-r--r--mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ToolsetDefinitionLocations.cs39
-rw-r--r--mcs/class/Microsoft.Build.Engine/Microsoft.Build.Engine.dll.sources4
-rw-r--r--mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ChangeLog13
-rw-r--r--mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/Consts.cs24
-rw-r--r--mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/EngineTest.cs118
-rw-r--r--mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ProjectTest.cs6
-rw-r--r--mcs/class/Microsoft.Build.Engine/Test/test-config-file-net-3.515
-rw-r--r--mcs/class/Microsoft.Build.Engine/Test/test-config-file-net-4.015
-rw-r--r--mcs/class/Microsoft.Build.Engine/Test/various/Build.cs52
-rw-r--r--mcs/class/Microsoft.Build.Engine/Test/various/ChangeLog4
-rw-r--r--mcs/class/Microsoft.Build.Framework/ChangeLog7
-rw-r--r--mcs/class/Microsoft.Build.Framework/Makefile4
-rw-r--r--mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework.dll.sources1
-rw-r--r--mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/ChangeLog4
-rw-r--r--mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/IBuildEngine2.cs59
-rw-r--r--mcs/class/Microsoft.Build.Tasks/ChangeLog11
-rw-r--r--mcs/class/Microsoft.Build.Tasks/Makefile32
-rw-r--r--mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/AssemblyResolver.cs112
-rw-r--r--mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/ChangeLog72
-rw-r--r--mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/Copy.cs27
-rw-r--r--mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/Csc.cs4
-rw-r--r--mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/GetFrameworkPath.cs9
-rw-r--r--mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/MSBuild.cs30
-rw-r--r--mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/ResolveAssemblyReference.cs12
-rw-r--r--mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/Vbc.cs63
-rw-r--r--mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks_test.dll.sources2
-rw-r--r--mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/AssignProjectConfigurationTest.cs8
-rwxr-xr-xmcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/AssignTargetPathTest.cs1
-rw-r--r--mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/ChangeLog19
-rwxr-xr-xmcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/CreateCSharpManifestResourceNameTest.cs11
-rw-r--r--mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/CreateItemTest.cs4
-rw-r--r--mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/CreateVisualBasicManifestResourceNameTest.cs11
-rw-r--r--mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/FindAppConfigFileTest.cs6
-rw-r--r--mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/RemoveDuplicatesTest.cs2
-rw-r--r--mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/TaskBatchingTest.cs22
-rwxr-xr-xmcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/WriteLinesToFileTest.cs2
-rw-r--r--mcs/class/Microsoft.Build.Tasks/Test/test-config-file-net-3.515
-rw-r--r--mcs/class/Microsoft.Build.Tasks/Test/test-config-file-net-4.015
-rw-r--r--mcs/class/Microsoft.Build.Utilities/ChangeLog7
-rw-r--r--mcs/class/Microsoft.Build.Utilities/Makefile8
-rw-r--r--mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ChangeLog21
-rw-r--r--mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/TargetDotNetFrameworkVersion.cs5
-rw-r--r--mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/Task.cs4
-rw-r--r--mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolLocationHelper.cs23
-rw-r--r--mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolTask.cs121
-rw-r--r--mcs/class/Microsoft.Build.Utilities/Mono.XBuild.Utilities/ReservedNameUtils.cs3
61 files changed, 1693 insertions, 350 deletions
diff --git a/mcs/class/Microsoft.Build.Engine/ChangeLog b/mcs/class/Microsoft.Build.Engine/ChangeLog
index 0052a5560ce..11e68a37062 100644
--- a/mcs/class/Microsoft.Build.Engine/ChangeLog
+++ b/mcs/class/Microsoft.Build.Engine/ChangeLog
@@ -1,3 +1,20 @@
+2010-04-06 Ankit Jain <jankit@novell.com>
+
+ * Makefile (EXTRA_DISTFILES): Remove TestTasks.dll.config .
+
+2010-04-03 Ankit Jain <jankit@novell.com>
+
+ * Makefile: Use the correct assembly name for MS.Build.Utilities*
+ for 3.5 and 4.0 profiles. Copy the .config files for the test
+ assembly.
+ Import tools/xbuild/xbuild_targets.make, which copies the target
+ and tasks file in the correct place, to allow running tests
+ with different toolsversion.
+ * Microsoft.Build.Engine.dll.sources: Add LogExtensions.cs,
+ Toolset.cs, ToolsetDefinitionLocations.cs and ToolsetCollection.cs .
+ * Test/test-config-file-net-3.5: New.
+ * Test/test-config-file-net-4.0: New.
+
2010-02-19 Ankit Jain <jankit@novell.com>
* Microsoft.Build.Engine.dll.sources: Add ProjectLoadSettings.cs .
diff --git a/mcs/class/Microsoft.Build.Engine/Makefile b/mcs/class/Microsoft.Build.Engine/Makefile
index d46bf87bf13..07f9e6fc299 100644
--- a/mcs/class/Microsoft.Build.Engine/Makefile
+++ b/mcs/class/Microsoft.Build.Engine/Makefile
@@ -11,23 +11,56 @@ NO_TEST = yes
NO_SIGN_ASSEMBLY = yes
endif
+ifeq (3.5, $(FRAMEWORK_VERSION))
+NAME_SUFFIX = .v3.5
+else
+ifeq (4.0, $(FRAMEWORK_VERSION))
+NAME_SUFFIX = .v4.0
+endif
+endif
+
LIB_MCS_FLAGS = \
/r:$(corlib) \
/r:System.dll \
+ /r:System.Core.dll \
/r:System.Xml.dll \
/r:Microsoft.Build.Framework.dll \
- /r:Microsoft.Build.Utilities.dll
+ /r:Microsoft.Build.Utilities$(NAME_SUFFIX).dll
TEST_MCS_FLAGS = \
/r:Microsoft.Build.Framework.dll \
- /r:Microsoft.Build.Utilities.dll
+ /r:Microsoft.Build.Utilities$(NAME_SUFFIX).dll
EXTRA_DISTFILES = \
Test/resources/TestTasks.cs \
- Test/resources/*.*proj
+ Test/resources/*.*proj \
+ Test/test-config-file*
Test/resources/TestTasks.dll: Test/resources/TestTasks.cs
- $(CSCOMPILE) Test/resources/TestTasks.cs /r:Microsoft.Build.Framework.dll /r:Microsoft.Build.Utilities.dll /target:library
+ $(CSCOMPILE) Test/resources/TestTasks.cs /r:Microsoft.Build.Framework.dll /r:Microsoft.Build.Utilities$(NAME_SUFFIX).dll /target:library
+
+clean-local: clean-test-tasks
+
+clean-test-tasks:
+ rm -f Test/resources/TestTasks.dll
+
+test-local: copy-config
+
+ifeq (net_4_0, $(PROFILE))
+copy-config:
+ cp Test/test-config-file-net-4.0 $(test_lib).config
+else
+ifeq (net_3_5, $(PROFILE))
+copy-config:
+ cp Test/test-config-file-net-3.5 $(test_lib).config
+else
+copy-config:
+endif
+endif
+
+export TESTING_MONO=a
+XBUILD_DIR=../../tools/xbuild
+include $(XBUILD_DIR)/xbuild_targets.make
test-local: Test/resources/TestTasks.dll
diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildEngine.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildEngine.cs
index 530685e0d37..1d48f922501 100644
--- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildEngine.cs
+++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildEngine.cs
@@ -32,7 +32,7 @@ using System.Collections;
using Microsoft.Build.Framework;
namespace Microsoft.Build.BuildEngine {
- internal class BuildEngine : IBuildEngine {
+ internal class BuildEngine : IBuildEngine2 {
Engine engine;
int columnNumberOfTaskNode;
@@ -60,7 +60,16 @@ namespace Microsoft.Build.BuildEngine {
IDictionary globalProperties,
IDictionary targetOutputs)
{
+ return BuildProjectFile (projectFileName, targetNames, globalProperties, targetOutputs, null);
+ }
+
+ public bool BuildProjectFile (string projectFileName,
+ string[] targetNames,
+ IDictionary globalProperties,
+ IDictionary targetOutputs, string toolsVersion)
+ {
if (String.IsNullOrEmpty (projectFileName)) {
+ project.ToolsVersion = toolsVersion;
return engine.BuildProject (project, targetNames, targetOutputs,
BuildSettings.DoNotResetPreviouslyBuiltTargets);
} else {
@@ -71,10 +80,21 @@ namespace Microsoft.Build.BuildEngine {
(string) de.Key, (string) de.Value,
PropertyType.Global));
return engine.BuildProjectFile (projectFileName,
- targetNames, bpg, targetOutputs, BuildSettings.DoNotResetPreviouslyBuiltTargets);
+ targetNames, bpg, targetOutputs, BuildSettings.DoNotResetPreviouslyBuiltTargets, toolsVersion);
}
}
+ public bool BuildProjectFilesInParallel (string[] projectFileNames,
+ string [] targetNames,
+ IDictionary[] globalProperties,
+ IDictionary[] targetOutputsPerProject,
+ string[] toolsVersion,
+ bool useResultsCache,
+ bool unloadProjectsOnCompletion)
+ {
+ throw new NotImplementedException ();
+ }
+
// Raises a custom event to all registered loggers.
public void LogCustomEvent (CustomBuildEventArgs e)
{
@@ -84,7 +104,21 @@ namespace Microsoft.Build.BuildEngine {
// Raises an error to all registered loggers.
public void LogErrorEvent (BuildErrorEventArgs e)
{
- engine.EventSource.FireErrorRaised (this, e);
+ if (ContinueOnError) {
+ // log the error as a warning
+ LogWarningEvent (new BuildWarningEventArgs (
+ e.Subcategory, e.Code, e.File, e.LineNumber, e.ColumnNumber,
+ e.EndLineNumber, e.EndColumnNumber, e.Message,
+ e.HelpKeyword, e.SenderName));
+
+ LogMessageEvent (new BuildMessageEventArgs (
+ "Previous error was converted to a warning as the " +
+ "task was called with ContinueOnError=true.",
+ null, null, MessageImportance.Normal));
+
+ } else {
+ engine.EventSource.FireErrorRaised (this, e);
+ }
}
// Raises a message event to all registered loggers.
@@ -114,6 +148,10 @@ namespace Microsoft.Build.BuildEngine {
public string ProjectFileOfTaskNode {
get { return taskfile; }
}
+
+ public bool IsRunningMultipleNodes {
+ get { return false; }
+ }
}
}
diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildTask.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildTask.cs
index 9edeeb5a820..38bdad84bfa 100644
--- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildTask.cs
+++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildTask.cs
@@ -176,27 +176,31 @@ namespace Microsoft.Build.BuildEngine {
void LogError (string message,
params object[] messageArgs)
{
- BuildErrorEventArgs beea = new BuildErrorEventArgs (
- null, null, null, 0, 0, 0, 0, String.Format (message, messageArgs),
- null, null);
- parentTarget.Project.ParentEngine.EventSource.FireErrorRaised (this, beea);
+ parentTarget.Project.ParentEngine.LogError (message, messageArgs);
}
void LogMessage (MessageImportance importance,
string message,
params object[] messageArgs)
{
- BuildMessageEventArgs bmea = new BuildMessageEventArgs (
- String.Format (message, messageArgs), null,
- null, importance);
- parentTarget.Project.ParentEngine.EventSource.FireMessageRaised (this, bmea);
+ parentTarget.Project.ParentEngine.LogMessage (importance, message, messageArgs);
}
ITask InitializeTask ()
{
ITask task;
- task = (ITask)Activator.CreateInstance (this.Type);
+ try {
+ task = (ITask)Activator.CreateInstance (this.Type);
+ } catch (InvalidCastException) {
+ LogMessage (MessageImportance.Low, "InvalidCastException, ITask: {0} Task type: {1}",
+ typeof (ITask).AssemblyQualifiedName, this.Type.AssemblyQualifiedName);
+ throw;
+ }
+ parentTarget.Project.ParentEngine.LogMessage (
+ MessageImportance.Low,
+ "Using task {0} from {1}", Name, this.Type.AssemblyQualifiedName);
+
task.BuildEngine = new BuildEngine (parentTarget.Project.ParentEngine, parentTarget.Project,
parentTarget.TargetFile, 0, 0, ContinueOnError);
task_logger = new TaskLoggingHelper (task);
diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog
index 2e4b799e8e0..b0c3c37b508 100644
--- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog
+++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog
@@ -1,3 +1,85 @@
+2010-06-04 Ankit Jain <jankit@novell.com>
+
+ * Import.cs (EvaluateProjectPath): Add a hack to support multiple
+ msbuild extension paths. Paths can be specified via the environment
+ variable - $MSBuildExtensionsPath . ~/.config/xbuild/tasks is also
+ checked for extensions, besides the default location.
+ This explicitly looks for a "$(MSBuildExtensionsPath)" in the import
+ expression and tries to replace that with possible paths, till it
+ finds the file. In rest of the project, the property would resolve
+ to its single default value.
+
+2010-06-03 Ankit Jain <jankit@novell.com>
+
+ * Engine.cs (GetLoadedProject): Return null if project not found.
+ Based on a patch by Dale Ragan <dale.ragan@sinesignal.com> .
+
+2010-05-28 Ankit Jain <jankit@novell.com>
+
+ Fix bug #485841.
+ * DirectoryScanner.cs (ProcessInclude): Set %(RecursiveDir) only if
+ the '**' wildcard was found in the original Include.
+
+2010-04-10 Ankit Jain <jankit@novell.com>
+
+ * Project.cs (InitializeProperties): Set MSBuildBinPath to the current
+ tools path.
+
+2010-04-10 Ankit Jain <jankit@novell.com>
+
+ * TaskEngine.cs (Prepare): Throw InvalidProjectFileException instead of a generic
+ Exception.
+
+2010-04-10 Ankit Jain <jankit@novell.com>
+
+ * ConsoleLogger.cs (EventsToString): If the target being executed is
+ from an imported file, then show that.
+
+2010-04-10 Ankit Jain <jankit@novell.com>
+
+ * Project.cs: Add property MSBuildExtensionsPath32, used by silverlight
+ projects.
+
+2010-04-07 Ankit Jain <jankit@novell.com>
+
+ * ConsoleLogger.cs: Dump items and properties when a project starts
+ to build. Useful for debugging.
+ * Engine.cs (LogProjectStarted): Set the properties and items also,
+ for the project started event.
+ * Project.cs (EvaluatedPropertiesAsDictionaryEntries): New.
+ (EvaluatedItemsByNameAsDictionaryEntries): New. Required for
+ ProjectStartedEvent .
+
+2010-04-03 Ankit Jain <jankit@novell.com>
+
+ * BuildEngine.cs: Implement IBuildEngine2 instead of
+ IBuildEngine.
+ * BuildTasks.cs: Use the new extension methods for logging.
+ (InitializeTask): Emit a message informing about the assembly
+ from which the task is being loaded. Emit a useful debug message
+ incase of a InvalidCastException.
+ * Engine.cs: Add missing methods, constructors and properties related
+ to ToolsVersion support. Setup a default set of Toolsets.
+ Keep separate taskdbs' per ToolsVersion. The common tasks
+ would come from different *.tasks file, and use different
+ task assemblies.
+ (DefaultToolsVersion): Correctly set this based on the profile.
+ * LogExtensions.cs: New. Extension methods on Engine, for logging.
+ * Project.cs: Add missing methods/contructors/properties related
+ to ToolsVersion support. Add reserved properties -
+ MSBuildToolsPath and MSBuildToolsVersion .
+ * Toolset.cs: New.
+ * ToolsetCollection.cs: New.
+ * ToolsetDefinitionLocations.cs: New.
+
+2010-03-04 Ankit Jain <jankit@novell.com>
+
+ * BuildEngine.cs (LogErrorEvent): Log as warning, if
+ ContinueOnError==true, and log a corresponding message.
+ * TargetBatchingImpl.cs: Refactor to share code between the
+ batched and unbatched case. If a task fails and
+ ContinueOnError==true, then ignore the failed state.
+
2010-02-19 Ankit Jain <jankit@novell.com>
* BuildItem.cs: Track api changes.
diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConsoleLogger.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConsoleLogger.cs
index 8114c79c6c3..02d0179fb3f 100644
--- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConsoleLogger.cs
+++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConsoleLogger.cs
@@ -29,6 +29,7 @@
using System;
using System.Runtime.InteropServices;
+using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Security;
@@ -283,6 +284,8 @@ namespace Microsoft.Build.BuildEngine {
String.IsNullOrEmpty (args.TargetNames) ? "default" : args.TargetNames));
ResetColor ();
WriteLine (String.Empty);
+ DumpProperties (args.Properties);
+ DumpItems (args.Items);
PushEvent (args);
}
@@ -405,7 +408,7 @@ namespace Microsoft.Build.BuildEngine {
public void CustomEventHandler (object sender, CustomBuildEventArgs args)
{
}
-
+
private void WriteLine (string message)
{
if (indent > 0) {
@@ -436,6 +439,7 @@ namespace Microsoft.Build.BuildEngine {
{
StringBuilder sb = new StringBuilder ();
+ string last_imported_target_file = String.Empty;
for (int i = 0; i < events.Count; i ++) {
BuildStatusEventArgs args = events [i];
ProjectStartedEventArgs pargs = args as ProjectStartedEventArgs;
@@ -444,12 +448,20 @@ namespace Microsoft.Build.BuildEngine {
String.IsNullOrEmpty (pargs.TargetNames) ?
"default targets" :
pargs.TargetNames);
+ last_imported_target_file = String.Empty;
continue;
}
TargetStartedEventArgs targs = args as TargetStartedEventArgs;
- if (targs != null)
+ if (targs != null) {
+ if (targs.TargetFile != targs.ProjectFile && targs.TargetFile != last_imported_target_file)
+ // target from an imported file,
+ // and it hasn't been mentioned as yet
+ sb.AppendFormat ("{0} ", targs.TargetFile);
+
+ last_imported_target_file = targs.TargetFile;
sb.AppendFormat ("({0} target) ->\n", targs.TargetName);
+ }
}
return sb.ToString ();
@@ -572,6 +584,59 @@ namespace Microsoft.Build.BuildEngine {
return false;
}
+ void DumpProperties (IEnumerable properties)
+ {
+ if (!IsVerbosityGreaterOrEqual (LoggerVerbosity.Diagnostic))
+ return;
+
+ SetColor (eventColor);
+ WriteLine ("\n");
+ WriteLine ("Initial Properties:");
+ ResetColor ();
+
+ if (properties == null)
+ return;
+
+ var dict = new SortedDictionary<string, string> ();
+ foreach (DictionaryEntry de in properties)
+ dict [(string)de.Key] = (string)de.Value;
+
+ foreach (KeyValuePair<string, string> pair in dict)
+ WriteLine (String.Format ("{0} = {1}", pair.Key, pair.Value));
+ WriteLine ("\n");
+ }
+
+ void DumpItems (IEnumerable items)
+ {
+ if (!IsVerbosityGreaterOrEqual (LoggerVerbosity.Diagnostic) || items == null)
+ return;
+
+ SetColor (eventColor);
+ WriteLine ("\n");
+ WriteLine ("Initial Items:");
+ ResetColor ();
+ if (items == null)
+ return;
+
+ var items_table = new SortedDictionary<string, List<ITaskItem>> ();
+ foreach (DictionaryEntry de in items) {
+ string key = (string)de.Key;
+ if (!items_table.ContainsKey (key))
+ items_table [key] = new List<ITaskItem> ();
+
+ items_table [key].Add ((ITaskItem) de.Value);
+ }
+
+ foreach (string name in items_table.Keys) {
+ WriteLine (name);
+ indent ++;
+ foreach (ITaskItem item in items_table [name])
+ WriteLine (item.ItemSpec);
+ indent--;
+ }
+ WriteLine ("\n");
+ }
+
public string Parameters {
get {
return parameters;
diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/DirectoryScanner.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/DirectoryScanner.cs
index 904a979b851..4215deb0fb4 100644
--- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/DirectoryScanner.cs
+++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/DirectoryScanner.cs
@@ -114,10 +114,12 @@ namespace Microsoft.Build.BuildEngine {
if (!excludedItems.ContainsKey (fi.FullName)) {
TaskItem item = new TaskItem (include_item);
item.ItemSpec = fi.FullName;
- string rec_dir = Path.GetDirectoryName (fi.FullName.Substring (wildcard_offset));
- if (rec_dir.Length > 0)
- rec_dir += Path.DirectorySeparatorChar;
- item.SetMetadata ("RecursiveDir", rec_dir);
+ if (wildcard_offset >= 0) {
+ string rec_dir = Path.GetDirectoryName (fi.FullName.Substring (wildcard_offset));
+ if (rec_dir.Length > 0)
+ rec_dir += Path.DirectorySeparatorChar;
+ item.SetMetadata ("RecursiveDir", rec_dir);
+ }
includedItems.Add (item);
}
}
diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs
index a8f6a067a2c..e211551f9c7 100644
--- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs
+++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs
@@ -40,16 +40,17 @@ namespace Microsoft.Build.BuildEngine {
string binPath;
bool buildEnabled;
- TaskDatabase defaultTasks;
- bool defaultTasksRegistered;
+ Dictionary<string, TaskDatabase> defaultTasksTableByToolsVersion;
const string defaultTasksProjectName = "Microsoft.Common.tasks";
EventSource eventSource;
bool buildStarted;
+ ToolsetDefinitionLocations toolsetLocations;
BuildPropertyGroup global_properties;
//IDictionary importedProjects;
List <ILogger> loggers;
//bool onlyLogCriticalEvents;
Dictionary <string, Project> projects;
+ string defaultToolsVersion;
// the key here represents the project+target+global_properties set
Dictionary <string, ITaskItem[]> builtTargetsOutputByName;
@@ -68,6 +69,25 @@ namespace Microsoft.Build.BuildEngine {
{
}
+ public Engine (ToolsetDefinitionLocations locations)
+ : this (ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version20))
+ {
+ toolsetLocations = locations;
+ }
+
+ public Engine (BuildPropertyGroup globalProperties)
+ : this (ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version20))
+ {
+ this.global_properties = globalProperties;
+ }
+
+ public Engine (BuildPropertyGroup globalProperties, ToolsetDefinitionLocations locations)
+ : this (ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version20))
+ {
+ this.global_properties = globalProperties;
+ toolsetLocations = locations;
+ }
+
// engine should be invoked with path where binary files are
// to find microsoft.build.tasks
public Engine (string binPath)
@@ -81,8 +101,25 @@ namespace Microsoft.Build.BuildEngine {
this.global_properties = new BuildPropertyGroup ();
this.builtTargetsOutputByName = new Dictionary<string, ITaskItem[]> ();
this.currentlyBuildingProjectsStack = new Stack<Project> ();
-
- RegisterDefaultTasks ();
+ this.Toolsets = new ToolsetCollection ();
+ LoadDefaultToolsets ();
+ defaultTasksTableByToolsVersion = new Dictionary<string, TaskDatabase> ();
+ GetDefaultTasks (DefaultToolsVersion);
+ }
+
+ //FIXME: should be loaded from config file
+ void LoadDefaultToolsets ()
+ {
+ Toolsets.Add (new Toolset ("2.0",
+ ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version20)));
+ Toolsets.Add (new Toolset ("3.0",
+ ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version30)));
+ Toolsets.Add (new Toolset ("3.5",
+ ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version35)));
+#if NET_4_0
+ Toolsets.Add (new Toolset ("4.0",
+ ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version40)));
+#endif
}
[MonoTODO]
@@ -128,27 +165,31 @@ namespace Microsoft.Build.BuildEngine {
if (targetNames == null)
return false;
+ if (defaultToolsVersion != null)
+ // it has been explicitly set, xbuild does this..
+ project.ToolsVersion = defaultToolsVersion;
return project.Build (targetNames, targetOutputs, buildFlags);
}
[MonoTODO]
public bool BuildProjectFile (string projectFile)
{
- throw new NotImplementedException ();
+ return BuildProjectFile (projectFile, new string [0]);
}
[MonoTODO]
public bool BuildProjectFile (string projectFile,
string targetName)
{
- throw new NotImplementedException ();
+ return BuildProjectFile (projectFile,
+ targetName == null ? new string [0] : new string [] {targetName});
}
[MonoTODO]
public bool BuildProjectFile (string projectFile,
string[] targetNames)
{
- throw new NotImplementedException ();
+ return BuildProjectFile (projectFile, targetNames, null);
}
[MonoTODO]
@@ -174,6 +215,16 @@ namespace Microsoft.Build.BuildEngine {
IDictionary targetOutputs,
BuildSettings buildFlags)
{
+ return BuildProjectFile (projectFile, targetNames, globalProperties, targetOutputs, buildFlags, null);
+ }
+
+ //FIXME: add a test for null @toolsVersion
+ public bool BuildProjectFile (string projectFile,
+ string[] targetNames,
+ BuildPropertyGroup globalProperties,
+ IDictionary targetOutputs,
+ BuildSettings buildFlags, string toolsVersion)
+ {
Project project;
if (projects.ContainsKey (projectFile)) {
@@ -197,6 +248,13 @@ namespace Microsoft.Build.BuildEngine {
}
try {
+ if (String.IsNullOrEmpty (toolsVersion) && defaultToolsVersion != null)
+ // it has been explicitly set, xbuild does this..
+ //FIXME: should this be cleared after building?
+ project.ToolsVersion = defaultToolsVersion;
+ else
+ project.ToolsVersion = toolsVersion;
+
return project.Build (targetNames, targetOutputs, buildFlags);
} finally {
if (globalProperties != null) {
@@ -217,8 +275,6 @@ namespace Microsoft.Build.BuildEngine {
public Project CreateNewProject ()
{
- if (defaultTasksRegistered)
- CheckBinPath ();
return new Project (this);
}
@@ -227,8 +283,10 @@ namespace Microsoft.Build.BuildEngine {
if (projectFullFileName == null)
throw new ArgumentNullException ("projectFullFileName");
- // FIXME: test it
- return projects [projectFullFileName];
+ Project project;
+ projects.TryGetValue (projectFullFileName, out project);
+
+ return project;
}
internal void RemoveLoadedProject (Project p)
@@ -328,13 +386,15 @@ namespace Microsoft.Build.BuildEngine {
void LogProjectStarted (Project project, string [] target_names)
{
- ProjectStartedEventArgs psea;
+ string targets;
if (target_names == null || target_names.Length == 0)
- psea = new ProjectStartedEventArgs ("Project started.", null, project.FullFileName,
- String.Empty, null, null);
+ targets = String.Empty;
else
- psea = new ProjectStartedEventArgs ("Project started.", null, project.FullFileName,
- String.Join (";", target_names), null, null);
+ targets = String.Join (";", target_names);
+
+ ProjectStartedEventArgs psea = new ProjectStartedEventArgs ("Project started.", null, project.FullFileName, targets,
+ project.EvaluatedPropertiesAsDictionaryEntries, project.EvaluatedItemsByNameAsDictionaryEntries);
+
eventSource.FireProjectStarted (this, psea);
}
@@ -358,23 +418,44 @@ namespace Microsoft.Build.BuildEngine {
bfea = new BuildFinishedEventArgs ("Build finished.", null, succeeded);
eventSource.FireBuildFinished (this, bfea);
}
+
+ internal TaskDatabase GetDefaultTasks (string toolsVersion)
+ {
+ TaskDatabase db;
+ if (defaultTasksTableByToolsVersion.TryGetValue (toolsVersion, out db))
+ return db;
+
+ var toolset = Toolsets [toolsVersion];
+ if (toolset == null)
+ throw new Exception ("Unknown toolsversion: " + toolsVersion);
+
+ string toolsPath = toolset.ToolsPath;
+ string tasksFile = Path.Combine (toolsPath, defaultTasksProjectName);
+ this.LogMessage (MessageImportance.Low, "Loading default tasks for ToolsVersion: {0} from {1}", toolsVersion, tasksFile);
+
+ // set a empty taskdb here, because the project loading the tasks
+ // file will try to get the default task db
+ defaultTasksTableByToolsVersion [toolsVersion] = new TaskDatabase ();
+
+ db = defaultTasksTableByToolsVersion [toolsVersion] = RegisterDefaultTasks (tasksFile);
+
+ return db;
+ }
- void RegisterDefaultTasks ()
+ TaskDatabase RegisterDefaultTasks (string tasksFile)
{
- this.defaultTasksRegistered = false;
-
Project defaultTasksProject = CreateNewProject ();
+ TaskDatabase db;
- if (binPath != null) {
- if (File.Exists (Path.Combine (binPath, defaultTasksProjectName))) {
- defaultTasksProject.Load (Path.Combine (binPath, defaultTasksProjectName));
- defaultTasks = defaultTasksProject.TaskDatabase;
- } else
- defaultTasks = new TaskDatabase ();
- } else
- defaultTasks = new TaskDatabase ();
-
- this.defaultTasksRegistered = true;
+ if (File.Exists (tasksFile)) {
+ defaultTasksProject.Load (tasksFile);
+ db = defaultTasksProject.TaskDatabase;
+ } else {
+ this.LogWarning ("Default tasks file {0} not found, ignoring.", tasksFile);
+ db = new TaskDatabase ();
+ }
+
+ return db;
}
public string BinPath {
@@ -403,7 +484,31 @@ namespace Microsoft.Build.BuildEngine {
get { return global_properties; }
set { global_properties = value; }
}
+
+ public ToolsetCollection Toolsets {
+ get; private set;
+ }
+ public string DefaultToolsVersion {
+ get {
+ if (String.IsNullOrEmpty (defaultToolsVersion))
+#if NET_4_0
+ return "4.0";
+#elif NET_3_5
+ return "3.5";
+#else
+ return "2.0";
+#endif
+
+ return defaultToolsVersion;
+ }
+ set { defaultToolsVersion = value; }
+ }
+
+ public bool IsBuilding {
+ get { return buildStarted; }
+ }
+
public bool OnlyLogCriticalEvents {
get { return eventSource.OnlyLogCriticalEvents; }
set { eventSource.OnlyLogCriticalEvents = value; }
@@ -413,14 +518,6 @@ namespace Microsoft.Build.BuildEngine {
get { return eventSource; }
}
- internal bool DefaultTasksRegistered {
- get { return defaultTasksRegistered; }
- }
-
- internal TaskDatabase DefaultTasks {
- get { return defaultTasks; }
- }
-
internal Dictionary<string, ITaskItem[]> BuiltTargetsOutputByName {
get { return builtTargetsOutputByName; }
}
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 c35aa810edb..ecb45ae5a68 100644
--- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Import.cs
+++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Import.cs
@@ -31,12 +31,17 @@ using System;
using System.IO;
using System.Xml;
+using Microsoft.Build.Framework;
+
namespace Microsoft.Build.BuildEngine {
public class Import {
XmlElement importElement;
Project project;
ImportedProject originalProject;
string evaluatedProjectPath;
+
+ static string DotConfigExtensionsPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData),
+ Path.Combine ("xbuild", "tasks"));
internal Import (XmlElement importElement, Project project, ImportedProject originalProject)
{
@@ -82,10 +87,48 @@ namespace Microsoft.Build.BuildEngine {
string EvaluateProjectPath (string file)
{
- Expression exp;
+ if (file.IndexOf ("$(MSBuildExtensionsPath)") >= 0) {
+ // This is a *HACK* to support multiple paths for
+ // MSBuildExtensionsPath property. Normally it would
+ // get resolved to a single value, but here we special
+ // case it and try ~/.config/xbuild/tasks and any
+ // paths specified in the env var $MSBuildExtensionsPath .
+ //
+ // The property itself will resolve to the default
+ // location though, so you get in any other part of the
+ // project.
+
+ string envvar = Environment.GetEnvironmentVariable ("MSBuildExtensionsPath");
+ envvar = (envvar ?? String.Empty) + ":" + DotConfigExtensionsPath;
- exp = new Expression ();
- exp.Parse (file, ParseOptions.Split);
+ string [] paths = envvar.Split (new char [] {':'}, StringSplitOptions.RemoveEmptyEntries);
+ foreach (string path in paths) {
+ if (!Directory.Exists (path)) {
+ project.ParentEngine.LogMessage (MessageImportance.Low, "Extension path '{0}' not found, ignoring.", path);
+ continue;
+ }
+
+ string pfile = Path.GetFullPath (file.Replace ("\\", "/").Replace (
+ "$(MSBuildExtensionsPath)", path + Path.DirectorySeparatorChar));
+
+ var evaluated_path = EvaluatePath (pfile);
+ if (File.Exists (evaluated_path)) {
+ project.ParentEngine.LogMessage (MessageImportance.Low,
+ "{0}: Importing project {1} from extension path {2}", project.FullFileName, evaluated_path, path);
+ return pfile;
+ }
+ project.ParentEngine.LogMessage (MessageImportance.Low,
+ "{0}: Couldn't find project {1} for extension path {2}", project.FullFileName, evaluated_path, path);
+ }
+ }
+
+ return EvaluatePath (file);
+ }
+
+ string EvaluatePath (string path)
+ {
+ var exp = new Expression ();
+ exp.Parse (path, ParseOptions.Split);
return (string) exp.ConvertTo (project, typeof (string));
}
diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/LogExtensions.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/LogExtensions.cs
new file mode 100644
index 00000000000..030ea8aa86a
--- /dev/null
+++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/LogExtensions.cs
@@ -0,0 +1,183 @@
+//
+// LogExtensions.cs: Extension methods for logging on Engine
+//
+// Author:
+// Ankit Jain (jankit@novell.com)
+//
+// Copyright 2010 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+#if NET_2_0
+
+using System;
+using System.IO;
+using System.Text;
+using Microsoft.Build.Framework;
+
+namespace Microsoft.Build.BuildEngine
+{
+ static class LogExtensions
+ {
+ public static string FormatString (string unformatted,
+ params object[] args)
+ {
+ if (unformatted == null)
+ throw new ArgumentNullException ("unformatted");
+
+ if (args == null || args.Length == 0)
+ return unformatted;
+ else
+ return String.Format (unformatted, args);
+ }
+
+ public static void LogError (this Engine engine, string message,
+ params object[] messageArgs)
+ {
+ if (message == null)
+ throw new ArgumentNullException ("message");
+
+ BuildErrorEventArgs beea = new BuildErrorEventArgs (
+ null, null, null, 0, 0, 0, 0, FormatString (message, messageArgs),
+ null, null);
+ engine.EventSource.FireErrorRaised (engine, beea);
+ }
+
+ public static void LogError (this Engine engine, string subcategory, string errorCode,
+ string helpKeyword, string file,
+ int lineNumber, int columnNumber,
+ int endLineNumber, int endColumnNumber,
+ string message,
+ params object[] messageArgs)
+ {
+ if (message == null)
+ throw new ArgumentNullException ("message");
+
+ BuildErrorEventArgs beea = new BuildErrorEventArgs (
+ subcategory, errorCode, file, lineNumber,
+ columnNumber, endLineNumber, endColumnNumber,
+ FormatString (message, messageArgs), helpKeyword /*it's helpKeyword*/,
+ null /*it's senderName*/);
+
+ engine.EventSource.FireErrorRaised (engine, beea);
+ }
+
+ public static void LogErrorFromException (this Engine engine, Exception e)
+ {
+ LogErrorFromException (engine, e, true);
+ }
+
+ public static void LogErrorFromException (this Engine engine, Exception e,
+ bool showStackTrace)
+ {
+ LogErrorFromException (engine, e, showStackTrace, true, String.Empty);
+ }
+
+ [MonoTODO ("Arguments @showDetail and @file are not honored")]
+ public static void LogErrorFromException (this Engine engine, Exception e,
+ bool showStackTrace, bool showDetail, string file)
+ {
+ if (e == null)
+ throw new ArgumentNullException ("e");
+
+ StringBuilder sb = new StringBuilder ();
+ sb.Append (e.Message);
+ if (showStackTrace == true)
+ sb.Append (e.StackTrace);
+ BuildErrorEventArgs beea = new BuildErrorEventArgs (
+ null, null, null, 0, 0, 0, 0, sb.ToString (),
+ e.HelpLink, e.Source);
+ engine.EventSource.FireErrorRaised (engine, beea);
+ }
+
+ public static void LogMessage (this Engine engine, string message,
+ params object[] messageArgs)
+ {
+ LogMessage (engine, MessageImportance.Normal, message, messageArgs);
+ }
+
+ public static void LogMessage (this Engine engine, MessageImportance importance,
+ string message,
+ params object[] messageArgs)
+ {
+ if (message == null)
+ throw new ArgumentNullException ("message");
+
+ LogMessageFromText (engine, FormatString (message, messageArgs), importance);
+ }
+
+ public static bool LogMessageFromText (this Engine engine, string lineOfText,
+ MessageImportance importance)
+ {
+ if (lineOfText == null)
+ throw new ArgumentNullException ("lineOfText");
+
+ BuildMessageEventArgs bmea = new BuildMessageEventArgs (
+ lineOfText, null,
+ null, importance);
+
+ engine.EventSource.FireMessageRaised (engine, bmea);
+
+ return true;
+ }
+
+ public static void LogWarning (this Engine engine, string message,
+ params object[] messageArgs)
+ {
+ // FIXME: what about all the parameters?
+ BuildWarningEventArgs bwea = new BuildWarningEventArgs (
+ null, null, null, 0, 0, 0, 0, FormatString (message, messageArgs),
+ null, null);
+ engine.EventSource.FireWarningRaised (engine, bwea);
+ }
+
+ public static void LogWarning (this Engine engine, string subcategory, string warningCode,
+ string helpKeyword, string file,
+ int lineNumber, int columnNumber,
+ int endLineNumber, int endColumnNumber,
+ string message,
+ params object[] messageArgs)
+ {
+ BuildWarningEventArgs bwea = new BuildWarningEventArgs (
+ subcategory, warningCode, file, lineNumber,
+ columnNumber, endLineNumber, endColumnNumber,
+ FormatString (message, messageArgs), helpKeyword, null);
+ engine.EventSource.FireWarningRaised (engine, bwea);
+ }
+
+ public static void LogWarningFromException (this Engine engine, Exception e)
+ {
+ LogWarningFromException (engine, e, false);
+ }
+
+ public static void LogWarningFromException (this Engine engine, Exception e,
+ bool showStackTrace)
+ {
+ StringBuilder sb = new StringBuilder ();
+ sb.Append (e.Message);
+ if (showStackTrace)
+ sb.Append (e.StackTrace);
+ LogWarning (engine, null, null, null, null, 0, 0, 0, 0,
+ sb.ToString (), null);
+ }
+ }
+}
+
+#endif
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 b5b0b1aa811..0bda5abba45 100644
--- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs
+++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Project.cs
@@ -89,9 +89,14 @@ namespace Microsoft.Build.BuildEngine {
{
}
- public Project (Engine engine)
+ public Project (Engine engine) : this (engine, null)
+ {
+ }
+
+ public Project (Engine engine, string toolsVersion)
{
parentEngine = engine;
+ ToolsVersion = toolsVersion;
buildEnabled = ParentEngine.BuildEnabled;
xmlDocument = new XmlDocument ();
@@ -116,6 +121,7 @@ namespace Microsoft.Build.BuildEngine {
GlobalProperties.AddProperty (bp.Clone (true));
ProcessXml ();
+
}
[MonoTODO ("Not tested")]
@@ -793,8 +799,7 @@ namespace Microsoft.Build.BuildEngine {
last_item_group_containing = new Dictionary <string, BuildItemGroup> ();
taskDatabase = new TaskDatabase ();
- if (ParentEngine.DefaultTasksRegistered)
- taskDatabase.CopyTasks (ParentEngine.DefaultTasks);
+ taskDatabase.CopyTasks (ParentEngine.GetDefaultTasks (GetToolsVersionToUse ()));
initialTargets = new List<string> ();
defaultTargets = new string [0];
@@ -860,7 +865,7 @@ namespace Microsoft.Build.BuildEngine {
AddChoose (xe);
break;
default:
- throw new InvalidProjectFileException ("Invalid element in project file.");
+ throw new InvalidProjectFileException (String.Format ("Invalid element '{0}' in project file.", xe.Name));
}
}
}
@@ -927,9 +932,15 @@ namespace Microsoft.Build.BuildEngine {
EvaluatedProperties.AddProperty (new BuildProperty ("MSBuildProjectName",
Path.GetFileNameWithoutExtension (fullFileName),
PropertyType.Reserved));
- EvaluatedProperties.AddProperty (new BuildProperty ("MSBuildBinPath", parentEngine.BinPath, PropertyType.Reserved));
- EvaluatedProperties.AddProperty (new BuildProperty ("MSBuildToolsPath", parentEngine.BinPath, PropertyType.Reserved));
+ string toolsVersionToUse = GetToolsVersionToUse ();
+ string toolsPath = parentEngine.Toolsets [toolsVersionToUse].ToolsPath;
+ if (toolsPath == null)
+ throw new Exception ("Unknown toolsVersion: " + toolsVersionToUse);
+ EvaluatedProperties.AddProperty (new BuildProperty ("MSBuildBinPath", toolsPath, PropertyType.Reserved));
+ EvaluatedProperties.AddProperty (new BuildProperty ("MSBuildToolsPath", toolsPath, PropertyType.Reserved));
+ EvaluatedProperties.AddProperty (new BuildProperty ("MSBuildToolsVersion", toolsVersionToUse, PropertyType.Reserved));
EvaluatedProperties.AddProperty (new BuildProperty ("MSBuildExtensionsPath", ExtensionsPath, PropertyType.Reserved));
+ EvaluatedProperties.AddProperty (new BuildProperty ("MSBuildExtensionsPath32", ExtensionsPath, PropertyType.Reserved));
EvaluatedProperties.AddProperty (new BuildProperty ("MSBuildProjectDefaultTargets", DefaultTargets, PropertyType.Reserved));
EvaluatedProperties.AddProperty (new BuildProperty ("OS", OS, PropertyType.Environment));
@@ -942,6 +953,18 @@ namespace Microsoft.Build.BuildEngine {
EvaluatedProperties.AddProperty (new BuildProperty ("MSBuildProjectDirectory", projectDir, PropertyType.Reserved));
}
+
+ string GetToolsVersionToUse ()
+ {
+ if (String.IsNullOrEmpty (ToolsVersion)) {
+ if (HasToolsVersionAttribute)
+ return DefaultToolsVersion;
+ else
+ return parentEngine.DefaultToolsVersion;
+ } else {
+ return ToolsVersion;
+ }
+ }
void AddProjectExtensions (XmlElement xmlElement)
{
@@ -1077,7 +1100,19 @@ namespace Microsoft.Build.BuildEngine {
return evaluatedItemsByName;
}
}
-
+
+ internal IEnumerable EvaluatedItemsByNameAsDictionaryEntries {
+ get {
+ if (EvaluatedItemsByName.Count == 0)
+ yield break;
+
+ foreach (KeyValuePair<string, BuildItemGroup> pair in EvaluatedItemsByName) {
+ foreach (BuildItem bi in pair.Value)
+ yield return new DictionaryEntry (pair.Key, bi.ConvertToITaskItem (null, ExpressionOptions.ExpandItemRefs));
+ }
+ }
+ }
+
internal IDictionary <string, BuildItemGroup> EvaluatedItemsByNameIgnoringCondition {
get {
// FIXME: do we need to do this here?
@@ -1238,6 +1273,13 @@ namespace Microsoft.Build.BuildEngine {
}
}
+ internal IEnumerable EvaluatedPropertiesAsDictionaryEntries {
+ get {
+ foreach (BuildProperty bp in EvaluatedProperties)
+ yield return new DictionaryEntry (bp.Name, bp.Value);
+ }
+ }
+
public string FullFileName {
get { return fullFileName; }
set { fullFileName = value; }
@@ -1316,6 +1358,29 @@ namespace Microsoft.Build.BuildEngine {
get { return xmlDocument.InnerXml; }
}
+ // corresponds to the xml attribute
+ public string DefaultToolsVersion {
+ get {
+ if (xmlDocument != null)
+ return xmlDocument.DocumentElement.GetAttribute ("ToolsVersion");
+ return null;
+ }
+ set {
+ if (xmlDocument != null)
+ xmlDocument.DocumentElement.SetAttribute ("ToolsVersion", value);
+ }
+ }
+
+ public bool HasToolsVersionAttribute {
+ get {
+ return xmlDocument != null && xmlDocument.DocumentElement.HasAttribute ("ToolsVersion");
+ }
+ }
+
+ public string ToolsVersion {
+ get; internal set;
+ }
+
internal List<string> BuiltTargetKeys {
get { return builtTargetKeys; }
}
diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TargetBatchingImpl.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TargetBatchingImpl.cs
index e0d8d735d90..af8040e615b 100644
--- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TargetBatchingImpl.cs
+++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TargetBatchingImpl.cs
@@ -83,68 +83,57 @@ namespace Microsoft.Build.BuildEngine {
bool Run (Target target, out bool executeOnErrors)
{
executeOnErrors = false;
- if (buckets.Count > 0)
- return RunBatched (target, out executeOnErrors);
- else
- return RunUnbatched (target, out executeOnErrors);
- }
-
- bool RunBatched (Target target, out bool executeOnErrors)
- {
- bool result = true;
- executeOnErrors = false;
- foreach (Dictionary<string, BuildItemGroup> bucket in buckets) {
- LogTargetStarted (target);
- project.PushBatch (bucket, commonItemsByName);
- try {
- if (!BuildTargetNeeded ()) {
- LogTargetSkipped (target);
- continue;
- }
+ if (buckets.Count > 0) {
+ foreach (Dictionary<string, BuildItemGroup> bucket in buckets)
+ if (!RunTargetWithBucket (bucket, target, out executeOnErrors))
+ return false;
- for (int i = 0; i < target.BuildTasks.Count; i ++) {
- //FIXME: parsing attributes repeatedly
- BuildTask task = target.BuildTasks [i];
- result = new TaskBatchingImpl (project).Build (task, out executeOnErrors);
- if (!result && !task.ContinueOnError) {
- executeOnErrors = true;
- break;
- }
- }
- } finally {
- project.PopBatch ();
- LogTargetFinished (target, result);
- }
+ return true;
+ } else {
+ return RunTargetWithBucket (null, target, out executeOnErrors);
}
- return result;
}
- bool RunUnbatched (Target target, out bool executeOnErrors)
+ bool RunTargetWithBucket (Dictionary<string, BuildItemGroup> bucket, Target target, out bool executeOnErrors)
{
- bool result = true;
+ bool target_result = true;
executeOnErrors = false;
+
LogTargetStarted (target);
+ if (bucket != null)
+ project.PushBatch (bucket, commonItemsByName);
try {
if (!BuildTargetNeeded ()) {
LogTargetSkipped (target);
- LogTargetFinished (target, true);
return true;
}
- foreach (BuildTask bt in target.BuildTasks) {
+ for (int i = 0; i < target.BuildTasks.Count; i ++) {
+ //FIXME: parsing attributes repeatedly
+ BuildTask bt = target.BuildTasks [i];
+
TaskBatchingImpl batchingImpl = new TaskBatchingImpl (project);
- result = batchingImpl.Build (bt, out executeOnErrors);
+ bool task_result = batchingImpl.Build (bt, out executeOnErrors);
+ if (task_result)
+ continue;
+
+ // task failed, if ContinueOnError,
+ // ignore failed state for target
+ target_result = bt.ContinueOnError;
- if (!result && !bt.ContinueOnError) {
+ if (!bt.ContinueOnError) {
executeOnErrors = true;
- break;
+ return false;
}
+
}
} finally {
- LogTargetFinished (target, result);
+ if (bucket != null)
+ project.PopBatch ();
+ LogTargetFinished (target, target_result);
}
- return result;
+ return target_result;
}
// Parse target's Input and Output attributes to get list of referenced
diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TaskEngine.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TaskEngine.cs
index 485771de492..696ffbeedfb 100644
--- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TaskEngine.cs
+++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/TaskEngine.cs
@@ -95,7 +95,7 @@ namespace Microsoft.Build.BuildEngine {
if (TryGetObjectFromString (de.Value, currentProperty.PropertyType, out value))
values.Add (de.Key, value);
} catch (Exception e) {
- throw new Exception (String.Format (
+ throw new InvalidProjectFileException (String.Format (
"Error converting Property named '{0}' with value '{1}' to type {2}: {3}",
de.Key, de.Value, currentProperty.PropertyType, e.Message), e);
}
@@ -171,10 +171,10 @@ namespace Microsoft.Build.BuildEngine {
propertyInfo = taskType.GetProperty (taskParameter, BindingFlags.Public | BindingFlags.Instance |
BindingFlags.IgnoreCase);
if (propertyInfo == null)
- throw new Exception (String.Format (
+ throw new InvalidProjectFileException (String.Format (
"The parameter '{0}' was not found for the '{1}' task.", taskParameter, taskElement.Name));
if (!propertyInfo.IsDefined (outputAttribute, false))
- throw new Exception ("This is not output property.");
+ throw new InvalidProjectFileException ("This is not output property.");
o = propertyInfo.GetValue (task, null);
// FIXME: maybe we should throw an exception here?
diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Toolset.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Toolset.cs
new file mode 100644
index 00000000000..d7955176a4a
--- /dev/null
+++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Toolset.cs
@@ -0,0 +1,53 @@
+//
+// Toolset.cs
+//
+// Author:
+// Ankit Jain (jankit@novell.com)
+//
+// Copyright 2010 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+#if NET_2_0
+using System;
+
+namespace Microsoft.Build.BuildEngine
+{
+ public class Toolset
+ {
+ public Toolset (string toolsVersion, string toolsPath, BuildPropertyGroup buildProperties)
+ {
+ ToolsVersion = toolsVersion;
+ ToolsPath = toolsPath;
+ BuildProperties = buildProperties;
+ }
+
+ public Toolset (string toolsVersion, string toolsPath)
+ : this (toolsVersion, toolsPath, null)
+ {
+ }
+
+ public BuildPropertyGroup BuildProperties { get; private set; }
+
+ public string ToolsVersion { get; private set; }
+ public string ToolsPath { get; private set; }
+ }
+}
+#endif
diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ToolsetCollection.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ToolsetCollection.cs
new file mode 100644
index 00000000000..0c332d45d53
--- /dev/null
+++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ToolsetCollection.cs
@@ -0,0 +1,99 @@
+//
+// ToolsetCollection.cs
+//
+// Author:
+// Ankit Jain (jankit@novell.com)
+//
+// Copyright 2010 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+#if NET_2_0
+
+using System;
+using System.Collections.Generic;
+using System.Collections;
+
+namespace Microsoft.Build.BuildEngine
+{
+
+ public class ToolsetCollection : ICollection<Toolset>, IEnumerable<Toolset>, IEnumerable
+ {
+ List<Toolset> toolsets;
+
+ internal ToolsetCollection ()
+ {
+ toolsets = new List<Toolset> ();
+ }
+
+ public int Count
+ {
+ get { return toolsets.Count; }
+ }
+
+ public bool IsReadOnly { get { return false; } }
+
+ public Toolset this [string toolsVersion]
+ {
+ get { return toolsets.Find (item => item.ToolsVersion == toolsVersion); }
+ }
+
+ public void Add (Toolset item)
+ {
+ toolsets.Add (item);
+ }
+
+ public void Clear ()
+ {
+ toolsets.Clear ();
+ }
+
+ public bool Contains (string toolsVersion)
+ {
+ return toolsets.Exists (item => item.ToolsVersion == toolsVersion);
+ }
+
+ public bool Contains (Toolset item)
+ {
+ return toolsets.Contains (item);
+ }
+
+ public void CopyTo (Toolset[] array, int arrayIndex)
+ {
+ toolsets.CopyTo (array, arrayIndex);
+ }
+
+ public IEnumerator<Toolset> GetEnumerator ()
+ {
+ return toolsets.GetEnumerator ();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator ()
+ {
+ return toolsets.GetEnumerator ();
+ }
+
+ public bool Remove (Toolset item)
+ {
+ return toolsets.Remove (item);
+ }
+ }
+}
+#endif
diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ToolsetDefinitionLocations.cs b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ToolsetDefinitionLocations.cs
new file mode 100644
index 00000000000..6f5e106b8e9
--- /dev/null
+++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ToolsetDefinitionLocations.cs
@@ -0,0 +1,39 @@
+//
+// ToolsetDefinitionLocations.cs
+//
+// Author:
+// Ankit Jain (jankit@novell.com)
+//
+// Copyright 2010 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+#if NET_2_0
+
+namespace Microsoft.Build.BuildEngine
+{
+ public enum ToolsetDefinitionLocations
+ {
+ None,
+ ConfigurationFile,
+ Registry
+ }
+}
+#endif
diff --git a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.Engine.dll.sources b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.Engine.dll.sources
index 8f429b31a78..02bc4c2002f 100644
--- a/mcs/class/Microsoft.Build.Engine/Microsoft.Build.Engine.dll.sources
+++ b/mcs/class/Microsoft.Build.Engine/Microsoft.Build.Engine.dll.sources
@@ -46,6 +46,7 @@ Microsoft.Build.BuildEngine/InternalLoggerException.cs
Microsoft.Build.BuildEngine/InvalidProjectFileException.cs
Microsoft.Build.BuildEngine/IReference.cs
Microsoft.Build.BuildEngine/ItemReference.cs
+Microsoft.Build.BuildEngine/LogExtensions.cs
Microsoft.Build.BuildEngine/MetadataReference.cs
Microsoft.Build.BuildEngine/Project.cs
Microsoft.Build.BuildEngine/ProjectLoadSettings.cs
@@ -56,6 +57,9 @@ Microsoft.Build.BuildEngine/Target.cs
Microsoft.Build.BuildEngine/TaskDatabase.cs
Microsoft.Build.BuildEngine/TaskEngine.cs
Microsoft.Build.BuildEngine/Token.cs
+Microsoft.Build.BuildEngine/Toolset.cs
+Microsoft.Build.BuildEngine/ToolsetCollection.cs
+Microsoft.Build.BuildEngine/ToolsetDefinitionLocations.cs
Microsoft.Build.BuildEngine/UsingTask.cs
Microsoft.Build.BuildEngine/UsingTaskCollection.cs
Microsoft.Build.BuildEngine/Utilities.cs
diff --git a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ChangeLog b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ChangeLog
index 7a11426c773..a35b494d080 100644
--- a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ChangeLog
+++ b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ChangeLog
@@ -1,3 +1,16 @@
+2010-06-03 Ankit Jain <jankit@novell.com>
+
+ * EngineTest.cs (TestGetLoadedProject1):
+ Patch by Dale Ragan <dale.ragan@sinesignal.com> .
+
+2010-04-06 Ankit Jain <jankit@novell.com>
+
+ * Consts.cs (ToolsVersionString): New.
+ (GetTasksAsmPath): New.
+ * EngineTest.cs: Use the direct path to the tasks assembly
+ in the UsingTasks.
+ * ProjectTest.cs: Set ToolsVersion to the current profile.
+
2010-02-19 Ankit Jain <jankit@novell.com>
* ImportTest.cs (TestMissingImport*): Add new tests for missing
diff --git a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/Consts.cs b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/Consts.cs
index bae9a32d6e5..31a160850a1 100644
--- a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/Consts.cs
+++ b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/Consts.cs
@@ -26,6 +26,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
+using System.IO;
using Microsoft.Build.Utilities;
public static class Consts {
@@ -43,4 +44,27 @@ public static class Consts {
return ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version20);
}
}
+
+ public static string ToolsVersionString {
+ get {
+#if NET_4_0
+ return " ToolsVersion='4.0'";
+#elif NET_3_5
+ return " ToolsVersion='3.5'";
+#else
+ return String.Empty;
+#endif
+ }
+ }
+
+ public static string GetTasksAsmPath ()
+ {
+#if NET_4_0
+ return Path.Combine (ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version40), "Microsoft.Build.Tasks.v4.0.dll");
+#elif NET_3_5
+ return Path.Combine (ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version35), "Microsoft.Build.Tasks.v3.5.dll");
+#else
+ return Path.Combine (ToolLocationHelper.GetPathToDotNetFramework (TargetDotNetFrameworkVersion.Version20), "Microsoft.Build.Tasks.dll");
+#endif
+ }
}
diff --git a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/EngineTest.cs b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/EngineTest.cs
index e18e464cb91..49f229e70a1 100644
--- a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/EngineTest.cs
+++ b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/EngineTest.cs
@@ -324,8 +324,9 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
[Test]
public void TestGlobalProperties1 ()
{
- string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
- <UsingTask TaskName=""Microsoft.Build.Tasks.MSBuild"" AssemblyName=""Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
+ string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
+ + GetUsingTask ("MSBuild")
+ + @"
<Target Name=""main"">
<MSBuild Projects=""first.proj"" Targets = ""1;2""/>
<Message Text=""second""/>
@@ -333,9 +334,9 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
</Target>
</Project>";
- string firstProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
- <UsingTask TaskName=""Microsoft.Build.Tasks.MSBuild""
- AssemblyName=""Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
+ string firstProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
+ + GetUsingTask ("MSBuild")
+ + @"
<Target Name = ""1"">
<MSBuild Projects=""second.proj"" Properties=""foo=bar""/>
<MSBuild Projects=""second.proj"" Targets = ""TargetB"" Properties=""foo=foofoo""/>
@@ -363,8 +364,9 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
public void TestGlobalProperties1a ()
{
Directory.CreateDirectory ("Test/resources/foo");
- string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
- <UsingTask TaskName=""Microsoft.Build.Tasks.MSBuild"" AssemblyName=""Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
+ string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
+ + GetUsingTask ("MSBuild")
+ + @"
<Target Name=""main"">
<MSBuild Projects=""first.proj"" Targets = ""1;2""/>
<Message Text=""second""/>
@@ -372,9 +374,9 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
</Target>
</Project>";
- string firstProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
- <UsingTask TaskName=""Microsoft.Build.Tasks.MSBuild""
- AssemblyName=""Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
+ string firstProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
+ + GetUsingTask ("MSBuild")
+ + @"
<Target Name = ""1"">
<MSBuild Projects=""second.proj"" Properties=""foo=bar""/>
<MSBuild Projects=""second.proj"" Targets = ""TargetB"" Properties=""foo=foofoo""/>
@@ -401,8 +403,9 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
[Test]
public void TestGlobalProperties1b ()
{
- string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
- <UsingTask TaskName=""Microsoft.Build.Tasks.MSBuild"" AssemblyName=""Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
+ string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
+ + GetUsingTask ("MSBuild")
+ + @"
<Target Name=""main"">
<MSBuild Projects=""first.proj"" Targets = ""1;2""/>
<Message Text=""second""/>
@@ -410,9 +413,9 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
</Target>
</Project>";
- string firstProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
- <UsingTask TaskName=""Microsoft.Build.Tasks.MSBuild""
- AssemblyName=""Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
+ string firstProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
+ + GetUsingTask ("MSBuild")
+ + @"
<Target Name = ""1"">
<MSBuild Projects=""second.proj"" Properties=""foo=bar""/>
<MSBuild Projects=""second.proj""/>
@@ -439,8 +442,9 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
[Test]
public void TestGlobalProperties2 ()
{
- string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
- <UsingTask TaskName=""Microsoft.Build.Tasks.MSBuild"" AssemblyName=""Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
+ string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
+ + GetUsingTask ("MSBuild")
+ + @"
<Target Name=""main"">
<MSBuild Projects=""first.proj"" Targets = ""1""/>
<MSBuild Projects=""first.proj"" Targets = ""2""/>
@@ -449,9 +453,9 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
</Target>
</Project>";
- string firstProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
- <UsingTask TaskName=""Microsoft.Build.Tasks.MSBuild""
- AssemblyName=""Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
+ string firstProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
+ + GetUsingTask ("MSBuild")
+ + @"
<Target Name = ""1"">
<MSBuild Projects=""second.proj"" Properties=""foo=bar""/>
<MSBuild Projects=""second.proj"" Targets = ""TargetB"" Properties=""foo=foofoo""/>
@@ -478,8 +482,9 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
[Test]
public void TestGlobalProperties3 ()
{
- string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
- <UsingTask TaskName=""Microsoft.Build.Tasks.MSBuild"" AssemblyName=""Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
+ string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
+ + GetUsingTask ("MSBuild")
+ + @"
<Target Name=""main"">
<MSBuild Projects=""first.proj"" Targets = ""1""/>
<CallTarget Targets=""Call2""/>
@@ -491,9 +496,9 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
</Target>
</Project>";
- string firstProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
- <UsingTask TaskName=""Microsoft.Build.Tasks.MSBuild""
- AssemblyName=""Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
+ string firstProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
+ + GetUsingTask ("MSBuild")
+ + @"
<Target Name = ""1"">
<MSBuild Projects=""second.proj"" Properties=""foo=bar""/>
<MSBuild Projects=""second.proj"" Targets = ""TargetB"" Properties=""foo=foofoo""/>
@@ -521,8 +526,9 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
[Test]
public void TestGlobalProperties4 ()
{
- string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
- <UsingTask TaskName=""Microsoft.Build.Tasks.MSBuild"" AssemblyName=""Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
+ string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
+ + GetUsingTask ("MSBuild")
+ + @"
<Target Name=""main"">
<MSBuild Projects=""first.proj"" Targets = ""1""/>
<CallTarget Targets=""Call2""/>
@@ -534,9 +540,9 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
</Target>
</Project>";
- string firstProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
- <UsingTask TaskName=""Microsoft.Build.Tasks.MSBuild""
- AssemblyName=""Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
+ string firstProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
+ + GetUsingTask ("MSBuild")
+ + @"
<Target Name = ""1"">
<MSBuild Projects=""second.proj"" Properties=""foo=bar""/>
<MSBuild Projects=""second.proj"" Targets = ""TargetB"" Properties=""foo=foofoo""/>
@@ -568,8 +574,9 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
[Test]
public void TestGlobalProperties4a ()
{
- string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
- <UsingTask TaskName=""Microsoft.Build.Tasks.MSBuild"" AssemblyName=""Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
+ string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
+ + GetUsingTask ("MSBuild")
+ + @"
<Target Name=""main"">
<MSBuild Projects=""first.proj"" Targets = ""1""/>
<CallTarget Targets=""Call2""/>
@@ -581,9 +588,9 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
</Target>
</Project>";
- string firstProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
- <UsingTask TaskName=""Microsoft.Build.Tasks.MSBuild""
- AssemblyName=""Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
+ string firstProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
+ + GetUsingTask ("MSBuild")
+ + @"
<Target Name = ""1"">
<MSBuild Projects=""second.proj"" Properties=""foo=bar""/>
<MSBuild Projects=""second.proj"" Targets = ""TargetB"" Properties=""foo=foofoo""/>
@@ -615,8 +622,9 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
[Test]
public void TestGlobalProperties4b ()
{
- string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
- <UsingTask TaskName=""Microsoft.Build.Tasks.MSBuild"" AssemblyName=""Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
+ string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
+ + GetUsingTask ("MSBuild")
+ + @"
<Target Name=""main"">
<MSBuild Projects=""first.proj"" Targets = ""1""/>
<CallTarget Targets=""Call2""/>
@@ -628,9 +636,9 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
</Target>
</Project>";
- string firstProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
- <UsingTask TaskName=""Microsoft.Build.Tasks.MSBuild""
- AssemblyName=""Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
+ string firstProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
+ + GetUsingTask ("MSBuild")
+ + @"
<Target Name = ""1"">
<MSBuild Projects=""second.proj"" Properties=""foo=bar""/>
<MSBuild Projects=""second.proj"" Targets = ""TargetB"" Properties=""foo=foofoo""/>
@@ -666,8 +674,9 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
[Test]
public void TestGlobalProperties4c ()
{
- string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
- <UsingTask TaskName=""Microsoft.Build.Tasks.MSBuild"" AssemblyName=""Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
+ string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
+ + GetUsingTask ("MSBuild")
+ + @"
<Target Name=""main"">
<MSBuild Projects=""first.proj"" Targets = ""1""/>
<CallTarget Targets=""Call2""/>
@@ -679,9 +688,9 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
</Target>
</Project>";
- string firstProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
- <UsingTask TaskName=""Microsoft.Build.Tasks.MSBuild""
- AssemblyName=""Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
+ string firstProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
+ + GetUsingTask ("MSBuild")
+ + @"
<Target Name = ""1"">
<MSBuild Projects=""second.proj"" Properties=""foo=bar""/>
<MSBuild Projects=""second.proj"" Targets = ""TargetB"" Properties=""foo=foofoo""/>
@@ -714,10 +723,9 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
[Test]
public void TestMSBuildOutputs ()
{
- string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
- <UsingTask TaskName=""Microsoft.Build.Tasks.MSBuild""
- AssemblyName=""Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
-
+ string mainProject = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">"
+ + GetUsingTask ("MSBuild")
+ + @"
<ItemGroup>
<ProjectRef Include=""first.proj"">
<Prop3>value</Prop3>
@@ -802,6 +810,13 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
});
}
+ [Test]
+ public void TestGetLoadedProject1()
+ {
+ Project project = Engine.GlobalEngine.GetLoadedProject("foo.proj");
+ Assert.IsNull(project);
+ }
+
// Helper Methods for TestGlobalProperties*
void CreateAndCheckGlobalPropertiesTest (string main, string first, string second,
@@ -889,6 +904,9 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
}
}
-
+ public static string GetUsingTask (string taskName)
+ {
+ return "<UsingTask TaskName='Microsoft.Build.Tasks." + taskName + "' AssemblyFile='" + Consts.GetTasksAsmPath () + "' />";
+ }
}
}
diff --git a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ProjectTest.cs b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ProjectTest.cs
index cce13c6af67..5d92a43f5a5 100644
--- a/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ProjectTest.cs
+++ b/mcs/class/Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/ProjectTest.cs
@@ -1779,7 +1779,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
Engine engine = new Engine (Consts.BinPath);
Project project = engine.CreateNewProject ();
- string second = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""3.5"">
+ string second = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" " + Consts.ToolsVersionString + @">
<PropertyGroup>
<Prop1>InitialVal</Prop1>
</PropertyGroup>
@@ -1797,7 +1797,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
sw.Write (second);
}
- string third = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""3.5"">
+ string third = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" " + Consts.ToolsVersionString + @">
<PropertyGroup>
<ThirdProp>Third Value</ThirdProp>
</PropertyGroup>
@@ -1972,7 +1972,7 @@ namespace MonoTests.Microsoft.Build.BuildEngine {
[Test]
public void TestCaseSensitivityOfProjectElements ()
{
- string projectXml = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""3.5"">
+ string projectXml = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" " + Consts.ToolsVersionString + @">
<ItemGroup>
<Abc Include=""foo"">
<MetaDaTA1>md1</MetaDaTA1>
diff --git a/mcs/class/Microsoft.Build.Engine/Test/test-config-file-net-3.5 b/mcs/class/Microsoft.Build.Engine/Test/test-config-file-net-3.5
new file mode 100644
index 00000000000..7756bca8df1
--- /dev/null
+++ b/mcs/class/Microsoft.Build.Engine/Test/test-config-file-net-3.5
@@ -0,0 +1,15 @@
+<?xml version ="1.0"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
+ <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="3.5.0.0"/>
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="Microsoft.Build.Engine" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
+ <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="3.5.0.0"/>
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/mcs/class/Microsoft.Build.Engine/Test/test-config-file-net-4.0 b/mcs/class/Microsoft.Build.Engine/Test/test-config-file-net-4.0
new file mode 100644
index 00000000000..3c78f3b4ec8
--- /dev/null
+++ b/mcs/class/Microsoft.Build.Engine/Test/test-config-file-net-4.0
@@ -0,0 +1,15 @@
+<?xml version ="1.0"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
+ <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="4.0.0.0"/>
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="Microsoft.Build.Engine" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
+ <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="4.0.0.0"/>
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/mcs/class/Microsoft.Build.Engine/Test/various/Build.cs b/mcs/class/Microsoft.Build.Engine/Test/various/Build.cs
index 12a5bcc2482..e11bd393b0f 100644
--- a/mcs/class/Microsoft.Build.Engine/Test/various/Build.cs
+++ b/mcs/class/Microsoft.Build.Engine/Test/various/Build.cs
@@ -137,5 +137,57 @@ namespace MonoTests.Microsoft.Build.BuildEngine.Various {
Assert.IsNotNull (project.EvaluatedProperties ["A"], "A2");
Assert.IsNull (project.EvaluatedProperties ["B"], "A3");
}
+
+ [Test]
+ public void TestBuildContinueOnError ()
+ {
+ Engine engine;
+ Project project;
+
+ string documentString = @"
+ <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
+ <Target Name='A'>
+ <Error ContinueOnError='true' Text='text' />
+ <CreateProperty Value='A'>
+ <Output TaskParameter='Value' PropertyName='A'/>
+ </CreateProperty>
+ <Error ContinueOnError='true' Text='text' />
+ </Target>
+ </Project>
+ ";
+
+ engine = new Engine (Consts.BinPath);
+ project = engine.CreateNewProject ();
+ project.LoadXml (documentString);
+
+ Assert.IsTrue (project.Build ("A"), "A1");
+ Assert.IsNotNull (project.EvaluatedProperties["A"], "A2");
+ }
+
+ [Test]
+ public void TestBuildContinueOnErrorFalse ()
+ {
+ Engine engine;
+ Project project;
+
+ string documentString = @"
+ <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
+ <Target Name='A'>
+ <Error ContinueOnError='false' Text='text' />
+ <CreateProperty Value='A'>
+ <Output TaskParameter='Value' PropertyName='A'/>
+ </CreateProperty>
+ </Target>
+ </Project>
+ ";
+
+ engine = new Engine (Consts.BinPath);
+ project = engine.CreateNewProject ();
+ project.LoadXml (documentString);
+
+ Assert.IsFalse (project.Build ("A"), "A1");
+ Assert.IsNull (project.EvaluatedProperties["A"], "A2");
+ }
+
}
}
diff --git a/mcs/class/Microsoft.Build.Engine/Test/various/ChangeLog b/mcs/class/Microsoft.Build.Engine/Test/various/ChangeLog
index d459cc724b0..02476d68b35 100644
--- a/mcs/class/Microsoft.Build.Engine/Test/various/ChangeLog
+++ b/mcs/class/Microsoft.Build.Engine/Test/various/ChangeLog
@@ -1,3 +1,7 @@
+2010-03-04 Ankit Jain <jankit@novell.com>
+
+ * Build.cs (TestBuildContinueOnError*): New.
+
2010-02-19 Ankit Jain <jankit@novell.com>
* Items.cs (TestItemsWithWildcards): Check for RecursiveDir metadata also.
diff --git a/mcs/class/Microsoft.Build.Framework/ChangeLog b/mcs/class/Microsoft.Build.Framework/ChangeLog
index 74073fb0652..dea06412ca5 100644
--- a/mcs/class/Microsoft.Build.Framework/ChangeLog
+++ b/mcs/class/Microsoft.Build.Framework/ChangeLog
@@ -1,3 +1,10 @@
+2010-04-03 Ankit Jain <jankit@novell.com>
+
+ * Makefile: Import tools/xbuild/xbuild_targets.make, which copies
+ the target and tasks file in the correct place, to allow running
+ tests with different toolsversion.
+ * Microsoft.Build.Framework.dll.sources: Add IBuildEngine2.cs .
+
2006-04-19 Marek Sieradzki <marek.sieradzki@gmail.com>
* Microsoft.Build.Framework.targets: Removed.
diff --git a/mcs/class/Microsoft.Build.Framework/Makefile b/mcs/class/Microsoft.Build.Framework/Makefile
index 74043402bbc..0cb68bfac6c 100644
--- a/mcs/class/Microsoft.Build.Framework/Makefile
+++ b/mcs/class/Microsoft.Build.Framework/Makefile
@@ -17,5 +17,9 @@ LIB_MCS_FLAGS = \
include ../../build/library.make
+export TESTING_MONO=a
+XBUILD_DIR=../../tools/xbuild
+include $(XBUILD_DIR)/xbuild_targets.make
+
EXTRA_DISTFILES = \
Mono.XBuild.Framework/AssemblyLoadInfo.cs
diff --git a/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework.dll.sources b/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework.dll.sources
index 5be4904c10f..7e7d3a57db2 100644
--- a/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework.dll.sources
+++ b/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework.dll.sources
@@ -20,6 +20,7 @@ Microsoft.Build.Framework/CustomBuildEventHandler.cs
Microsoft.Build.Framework/ExternalProjectFinishedEventArgs.cs
Microsoft.Build.Framework/ExternalProjectStartedEventArgs.cs
Microsoft.Build.Framework/IBuildEngine.cs
+Microsoft.Build.Framework/IBuildEngine2.cs
Microsoft.Build.Framework/IEventSource.cs
Microsoft.Build.Framework/ILogger.cs
Microsoft.Build.Framework/ITask.cs
diff --git a/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/ChangeLog b/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/ChangeLog
index 47cfed8525e..0f14e7b1420 100644
--- a/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/ChangeLog
+++ b/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/ChangeLog
@@ -1,3 +1,7 @@
+2010-04-03 Ankit Jain <jankit@novell.com>
+
+ * IBuildEngine2.cs: New.
+
2006-12-19 Marek Sieradzki <marek.sieradzi@gmail.com>
* LoggerException.cs: Changed serialization names.
diff --git a/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/IBuildEngine2.cs b/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/IBuildEngine2.cs
new file mode 100644
index 00000000000..42b456c3a0c
--- /dev/null
+++ b/mcs/class/Microsoft.Build.Framework/Microsoft.Build.Framework/IBuildEngine2.cs
@@ -0,0 +1,59 @@
+//
+// IBuildEngine2.cs: Provides a way for task authors to use the functionality
+// of the MSBuild engine.
+//
+// Author:
+// Ankit Jain (jankit@novell.com)
+//
+// Copyright 2010 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+#if NET_2_0
+
+using System;
+using System.Collections;
+
+namespace Microsoft.Build.Framework
+{
+ public interface IBuildEngine2 : IBuildEngine
+ {
+ // Initiates a build of a project file. If the build is
+ // successful, the outputs (if any) of the specified targets
+ // are returned.
+ bool BuildProjectFile (string projectFileName,
+ string[] targetNames,
+ IDictionary globalProperties,
+ IDictionary targetOutputs, string toolsVersion);
+
+ bool BuildProjectFilesInParallel (string[] projectFileNames,
+ string [] targetNames,
+ IDictionary[] globalProperties,
+ IDictionary[] targetOutputsPerProject,
+ string[] toolsVersion,
+ bool useResultsCache,
+ bool unloadProjectsOnCompletion);
+
+ bool IsRunningMultipleNodes { get; }
+
+ }
+}
+
+#endif
diff --git a/mcs/class/Microsoft.Build.Tasks/ChangeLog b/mcs/class/Microsoft.Build.Tasks/ChangeLog
index 7e8c05ac911..ff531ad0138 100644
--- a/mcs/class/Microsoft.Build.Tasks/ChangeLog
+++ b/mcs/class/Microsoft.Build.Tasks/ChangeLog
@@ -1,3 +1,14 @@
+2010-04-03 Ankit Jain <jankit@novell.com>
+
+ * Makefile: Import tools/xbuild/xbuild_targets.make, which copies
+ the target and tasks file in the correct place, to allow running
+ tests with different toolsversion. Copy the config file for the
+ test assembly. Clean the generated test.dll .
+ Use the correct target assembly name for 4.0 profile
+ (ms.build.tasks.v4.0.dll), and for Utilities assembly.
+ * Microsoft.Build.Tasks_test.dll.sources: Use Consts.cs from Engine
+ instead of maintaining a copy here.
+
2010-03-02 Ankit Jain <jankit@novell.com>
Fix tests.
diff --git a/mcs/class/Microsoft.Build.Tasks/Makefile b/mcs/class/Microsoft.Build.Tasks/Makefile
index 70d2cb67752..34a542a1e1b 100644
--- a/mcs/class/Microsoft.Build.Tasks/Makefile
+++ b/mcs/class/Microsoft.Build.Tasks/Makefile
@@ -14,6 +14,10 @@ else
ifeq (3.5, $(FRAMEWORK_VERSION))
NAME_SUFFIX = .v3.5
+else
+ifeq (4.0, $(FRAMEWORK_VERSION))
+NAME_SUFFIX = .v4.0
+endif
endif
LIBRARY_NAME = Microsoft.Build.Tasks$(NAME_SUFFIX).dll
@@ -26,7 +30,7 @@ LIB_MCS_FLAGS = \
/r:System.Core.dll \
/r:System.Xml.dll \
/r:System.Windows.Forms.dll \
- /r:Microsoft.Build.Utilities.dll \
+ /r:Microsoft.Build.Utilities$(NAME_SUFFIX).dll \
/r:Microsoft.Build.Framework.dll \
/r:Microsoft.Build.Engine.dll
@@ -39,11 +43,35 @@ EXTRA_DISTFILES = \
Test/resources/test.cs \
Test/resources/Sample.cs \
Test/resources/Sample.vb \
- Test/resources/junk.txt
+ Test/resources/junk.txt \
+ Test/test-config-file*
test-local: Test/resources/test.dll
Test/resources/test.dll: Test/resources/test.cs
$(CSCOMPILE) -target:library Test/resources/test.cs
+clean-local: clean-test-dll
+
+clean-test-dll:
+ rm -f Test/resources/test.dll
+
+test-local: copy-config
+
+ifeq (net_4_0, $(PROFILE))
+copy-config:
+ cp Test/test-config-file-net-4.0 $(test_lib).config
+else
+ifeq (net_3_5, $(PROFILE))
+copy-config:
+ cp Test/test-config-file-net-3.5 $(test_lib).config
+else
+copy-config:
+endif
+endif
+
+export TESTING_MONO=a
+XBUILD_DIR=../../tools/xbuild
+include $(XBUILD_DIR)/xbuild_targets.make
+
include ../../build/library.make
diff --git a/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/AssemblyResolver.cs b/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/AssemblyResolver.cs
index d3568147ba4..ae822e68864 100644
--- a/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/AssemblyResolver.cs
+++ b/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/AssemblyResolver.cs
@@ -130,7 +130,7 @@ namespace Microsoft.Build.Tasks {
KeyValuePair<AssemblyName, string> pair;
if (gac_asm.NameToAssemblyNameCache.TryGetValue (key_aname.Name, out pair)) {
- if (AssemblyNamesCompatible (key_aname, pair.Key, specific_version, true)) {
+ if (AssemblyNamesCompatible (key_aname, pair.Key, specific_version)) {
// gac and tgt frmwk refs are not copied private
return GetResolvedReference (reference, pair.Value, pair.Key, false,
SearchPath.TargetFrameworkDirectory);
@@ -146,40 +146,55 @@ namespace Microsoft.Build.Tasks {
return null;
}
- public ResolvedReference FindInDirectory (ITaskItem reference, string directory, string [] file_extensions)
+ // Look for %(Identity).{dll|exe|..}
+ // if specific_version==true
+ // resolve if assembly names match
+ // else
+ // resolve the valid assembly
+ public ResolvedReference FindInDirectory (ITaskItem reference, string directory, string [] file_extensions, bool specific_version)
{
- if (reference.ItemSpec.IndexOf (',') < 0) {
- // Try as a filename
- string path = Path.Combine (directory, reference.ItemSpec);
- AssemblyName aname = GetAssemblyNameFromFile (path);
- if (aname != null)
- return GetResolvedReference (reference, path, aname, true, SearchPath.Directory);
-
- foreach (string extn in file_extensions) {
- string path_with_extn = path + extn;
- aname = GetAssemblyNameFromFile (path_with_extn);
- if (aname != null)
- return GetResolvedReference (reference, path_with_extn, aname, true,
- SearchPath.Directory);
- }
- }
+ string filename = reference.ItemSpec;
+ int comma_pos = filename.IndexOf (',');
+ if (comma_pos >= 0)
+ filename = filename.Substring (0, comma_pos);
- // Probably an assembly name
- AssemblyName key_aname = new AssemblyName (reference.ItemSpec);
+ // Try as a filename
+ string path = Path.GetFullPath (Path.Combine (directory, filename));
+ AssemblyName aname = specific_version ? new AssemblyName (reference.ItemSpec) : null;
+
+ ResolvedReference resolved_ref = ResolveReferenceForPath (path, reference, aname, null, SearchPath.Directory, specific_version);
+ if (resolved_ref != null)
+ return resolved_ref;
+
+ // try path + Include + {.dll|.exe|..}
foreach (string extn in file_extensions) {
- foreach (string file in Directory.GetFiles (directory, "*" + extn)) {
- AssemblyName found_aname = GetAssemblyNameFromFile (file);
- if (found_aname == null)
- // error already logged
- continue;
-
- //FIXME: Extract 'name' and look only for name.dll name.exe ?
- if (AssemblyNamesCompatible (key_aname, found_aname, false))
- return GetResolvedReference (reference, file, found_aname, true,
- SearchPath.Directory);
-
- LogSearchMessage ("Considered {0}, but assembly name wasn't compatible.", file);
- }
+ resolved_ref = ResolveReferenceForPath (path + extn, reference, aname, null, SearchPath.Directory, specific_version);
+ if (resolved_ref != null)
+ return resolved_ref;
+ }
+
+ return null;
+ }
+
+ // tries to resolve reference from the given file path, and compares assembly names
+ // if @specific_version == true, and logs accordingly
+ ResolvedReference ResolveReferenceForPath (string filename, ITaskItem reference, AssemblyName aname,
+ string error_message, SearchPath spath, bool specific_version)
+ {
+ AssemblyName found_aname = GetAssemblyNameFromFile (filename);
+ if (found_aname == null) {
+ if (error_message != null)
+ log.LogMessage (MessageImportance.Low, error_message);
+ return null;
+ }
+
+ if (!specific_version || AssemblyNamesCompatible (aname, found_aname, specific_version)) {
+ // Check compatibility only if specific_version == true
+ return GetResolvedReference (reference, filename, found_aname, true, spath);
+ } else {
+ LogSearchMessage ("Considered '{0}', but assembly name '{1}' did not match the " +
+ "expected '{2}' (SpecificVersion={3})", filename, found_aname, aname, specific_version);
+ log.LogMessage (MessageImportance.Low, "Assembly names are not compatible.");
}
return null;
@@ -190,8 +205,9 @@ namespace Microsoft.Build.Tasks {
TargetFrameworkAssemblies gac_asm = new TargetFrameworkAssemblies (directory);
foreach (string file in Directory.GetFiles (directory, "*.dll")) {
AssemblyName aname = GetAssemblyNameFromFile (file);
- gac_asm.NameToAssemblyNameCache [aname.Name] =
- new KeyValuePair<AssemblyName, string> (aname, file);
+ if (aname != null)
+ gac_asm.NameToAssemblyNameCache [aname.Name] =
+ new KeyValuePair<AssemblyName, string> (aname, file);
}
return gac_asm;
@@ -256,11 +272,13 @@ namespace Microsoft.Build.Tasks {
return rr;
}
+ // HintPath has a valid assembly
+ // if specific_version==true
+ // resolve if assembly names match
+ // else
+ // resolve the valid assembly
public ResolvedReference ResolveHintPathReference (ITaskItem reference, bool specific_version)
{
- AssemblyName name = new AssemblyName (reference.ItemSpec);
- ResolvedReference resolved = null;
-
string hintpath = reference.GetMetadata ("HintPath");
if (String.IsNullOrEmpty (hintpath)) {
LogSearchMessage ("HintPath attribute not found");
@@ -273,21 +291,9 @@ namespace Microsoft.Build.Tasks {
return null;
}
- AssemblyName found = GetAssemblyNameFromFile (hintpath);
- if (found == null) {
- log.LogMessage (MessageImportance.Low, "File at HintPath {0}, is either an invalid assembly or the file does not exist.", hintpath);
- return null;
- }
-
- if (AssemblyNamesCompatible (name, found, specific_version)) {
- resolved = GetResolvedReference (reference, hintpath, found, true, SearchPath.HintPath);
- } else {
- LogSearchMessage ("Considered {0}, but assembly name '{1}' did not match the " +
- "expected '{2}' (SpecificVersion={3})", hintpath, found, name, specific_version);
- log.LogMessage (MessageImportance.Low, "Assembly names are not compatible.");
- }
-
- return resolved;
+ return ResolveReferenceForPath (hintpath, reference, new AssemblyName (reference.ItemSpec),
+ String.Format ("File at HintPath {0}, is either an invalid assembly or the file does not exist.", hintpath),
+ SearchPath.HintPath, specific_version);
}
public AssemblyName GetAssemblyNameFromFile (string filename)
@@ -309,7 +315,7 @@ namespace Microsoft.Build.Tasks {
internal static bool AssemblyNamesCompatible (AssemblyName a, AssemblyName b, bool specificVersion)
{
- return AssemblyNamesCompatible (a, b, specificVersion, false);
+ return AssemblyNamesCompatible (a, b, specificVersion, true);
}
// if @specificVersion is true then match full name, else just the simple name
diff --git a/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/ChangeLog b/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/ChangeLog
index 3104cf56732..12a3248aa00 100644
--- a/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/ChangeLog
+++ b/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/ChangeLog
@@ -1,3 +1,75 @@
+2010-06-09 Ankit Jain <jankit@novell.com>
+
+ * ToolTask.cs: Don't check for tool's existence, as we might
+ not have the full path.
+
+2010-05-28 Ankit Jain <jankit@novell.com>
+
+ * AssemblyResolver.cs: Add some comments.
+
+2010-05-28 Ankit Jain <jankit@novell.com>
+
+ * AssemblyResolver.cs (FindInDirectory): Add a 'specific_version'
+ parameter. Look for reference.{dll|exe} instead of checking all
+ files in the directory. Compare assembly names only if
+ specific_version is true.
+ (ResolveHintPathReference): Extract code to check and compare assembly
+ names to ..
+ (ResolvedReferenceFromPath): .. this.
+ (AssemblyNamesCompatible): Change default value of @specificVersion to
+ true.
+ Track api changes.
+ * ResolveAssemblyReference.cs (ResolveReference): Specify
+ 'specific_version' in case of SearchPath.Directory.
+ (TryGetSpecificVersionValue): msbuild seems to look only for ',' in
+ the reference, instead of checking whether the assembly is strong
+ named.
+ (TryGetResolvedReferenceByAssemblyName): Track api changes.
+
+2010-05-28 Ankit Jain <jankit@novell.com>
+
+ * AssemblyResolver.cs (PopulateTargetFrameworkAssemblies):
+ Handle invalid dll, add a null check.
+
+2010-04-10 Ankit Jain <jankit@novell.com>
+
+ * GetFrameworkPath.cs (FrameworkVersion40Path): New.
+
+2010-04-10 Ankit Jain <jankit@novell.com>
+
+ * Copy.cs: Cleanly log errors, instead of throwing exceptions.
+
+2010-04-10 Ankit Jain <jankit@novell.com>
+
+ * Vbc.cs (LogEventsFromTextOutput):
+ * ToolTask.cs (LogEventsFromTextOutput): Emit the messages
+ that don't match the error regex, as is.
+
+2010-04-08 Ankit Jain <jankit@novell.com>
+
+ * Copy.cs: Handle non-existant source files.
+
+2010-04-08 Ankit Jain <jankit@novell.com>
+
+ Fix bug #594541
+ * Vbc.cs (LogEventsFromTextOutput): Override and correctly parse
+ output. Taken regex from monodevelop for this.
+
+2010-04-08 Ankit Jain <jankit@novell.com>
+
+ * Vbc.cs (ValidateParameters): Always return true, dummy implementation.
+
+2010-04-07 Ankit Jain <jankit@novell.com>
+
+ * MSBuild.cs: Emit global properties, if any. Sort the property
+ list.
+
+2010-04-03 Ankit Jain <jankit@novell.com>
+
+ * Csc.cs: Use dmcs as the compiler for 4.0 profile.
+ * MSBuild.cs (ToolsVersion): New.
+ Use toolsVersion for building.
+
2010-02-10 Ankit Jain <jankit@novell.com>
* GenerateResource.cs (CompileResourceFile): Check File.Exists
diff --git a/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/Copy.cs b/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/Copy.cs
index f704bceb446..a090e4716d4 100644
--- a/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/Copy.cs
+++ b/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/Copy.cs
@@ -57,10 +57,16 @@ namespace Microsoft.Build.Tasks {
List <ITaskItem> temporaryCopiedFiles = new List <ITaskItem> ();
if (sourceFiles != null && destinationFiles != null &&
- sourceFiles.Length != destinationFiles.Length)
- throw new Exception ("Number of source files is different than number of destination files.");
- if (destinationFiles != null && destinationFolder != null)
- throw new Exception ("You must specify only one attribute from DestinationFiles and DestinationFolder");
+ sourceFiles.Length != destinationFiles.Length) {
+ Log.LogError ("Number of source files is different than number of destination files.");
+ return false;
+ }
+
+ if (destinationFiles != null && destinationFolder != null) {
+ Log.LogError ("You must specify only one attribute from DestinationFiles and DestinationFolder");
+ return false;
+ }
+
if (destinationFiles != null && destinationFiles.Length > 0) {
for (int i = 0; i < sourceFiles.Length; i ++) {
ITaskItem sourceItem = sourceFiles [i];
@@ -68,6 +74,11 @@ namespace Microsoft.Build.Tasks {
string sourceFile = sourceItem.GetMetadata ("FullPath");
string destinationFile = destinationItem.GetMetadata ("FullPath");
+ if (!File.Exists (sourceFile)) {
+ Log.LogError ("Cannot copy {0} to {1}, as the source file doesn't exist.", sourceFile, destinationFile);
+ continue;
+ }
+
if (!skipUnchangedFiles || HasFileChanged (sourceFile, destinationFile))
CopyFile (sourceFile, destinationFile, true);
@@ -85,6 +96,11 @@ namespace Microsoft.Build.Tasks {
string filename = sourceItem.GetMetadata ("Filename") + sourceItem.GetMetadata ("Extension");
string destinationFile = Path.Combine (destinationDirectory,filename);
+ if (!File.Exists (sourceFile)) {
+ Log.LogError ("Cannot copy {0} to {1}, as the source file doesn't exist.", sourceFile, destinationFile);
+ continue;
+ }
+
if (!skipUnchangedFiles || directoryCreated ||
HasFileChanged (sourceFile, destinationFile))
CopyFile (sourceFile, destinationFile, false);
@@ -99,7 +115,8 @@ namespace Microsoft.Build.Tasks {
}
destinationFiles = temporaryDestinationFiles.ToArray ();
} else {
- throw new Exception ("You must specify DestinationFolder or DestinationFiles attribute.");
+ Log.LogError ("You must specify DestinationFolder or DestinationFiles attribute.");
+ return false;
}
copiedFiles = temporaryCopiedFiles.ToArray ();
diff --git a/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/Csc.cs b/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/Csc.cs
index 8b4217ab327..98399663276 100644
--- a/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/Csc.cs
+++ b/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/Csc.cs
@@ -187,7 +187,11 @@ namespace Microsoft.Build.Tasks {
protected override string ToolName {
get {
+#if NET_4_0
+ return Utilities.RunningOnWindows ? "dmcs.bat" : "dmcs";
+#else
return Utilities.RunningOnWindows ? "gmcs.bat" : "gmcs";
+#endif
}
}
diff --git a/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/GetFrameworkPath.cs b/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/GetFrameworkPath.cs
index f32d5279133..07e6169fc5a 100644
--- a/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/GetFrameworkPath.cs
+++ b/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/GetFrameworkPath.cs
@@ -87,6 +87,15 @@ namespace Microsoft.Build.Tasks {
}
}
+#if NET_4_0
+ [Output]
+ public string FrameworkVersion40Path {
+ get {
+ return ToolLocationHelper.GetPathToDotNetFramework (
+ TargetDotNetFrameworkVersion.Version40);
+ }
+ }
+#endif
}
}
diff --git a/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/MSBuild.cs b/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/MSBuild.cs
index 592a4122123..90c54cd38c5 100644
--- a/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/MSBuild.cs
+++ b/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/MSBuild.cs
@@ -65,9 +65,14 @@ namespace Microsoft.Build.Tasks {
string currentDirectory = Environment.CurrentDirectory;
Hashtable outputs;
- Dictionary<string, string> global_properties = SplitPropertiesToDictionary ();
+ var global_properties = SplitPropertiesToDictionary ();
Dictionary<string, ITaskItem> projectsByFileName = new Dictionary<string, ITaskItem> ();
+ Log.LogMessage (MessageImportance.Low, "Global Properties:");
+ if (global_properties != null)
+ foreach (KeyValuePair<string, string> pair in global_properties)
+ Log.LogMessage (MessageImportance.Low, "\t{0} = {1}", pair.Key, pair.Value);
+
foreach (ITaskItem project in projects) {
filename = project.GetMetadata ("FullPath");
if (!File.Exists (filename)) {
@@ -82,7 +87,14 @@ namespace Microsoft.Build.Tasks {
outputs = new Hashtable ();
try {
- result = BuildEngine.BuildProjectFile (filename, targets, global_properties, outputs);
+ // Order of precedence:
+ // %(Project.ToolsVersion) , ToolsVersion property
+ string tv = project.GetMetadata ("ToolsVersion");
+ if (String.IsNullOrEmpty (tv))
+ tv = ToolsVersion;
+ ThrowIfNotValidToolsVersion (tv);
+
+ result = BuildEngine2.BuildProjectFile (filename, targets, global_properties, outputs, tv);
} catch (InvalidProjectFileException e) {
Log.LogError ("Error building project {0}: {1}", filename, e.Message);
result = false;
@@ -127,6 +139,12 @@ namespace Microsoft.Build.Tasks {
return result;
}
+ void ThrowIfNotValidToolsVersion (string toolsVersion)
+ {
+ if (!String.IsNullOrEmpty (toolsVersion) && Engine.GlobalEngine.Toolsets [toolsVersion] == null)
+ throw new Exception (String.Format ("Unknown ToolsVersion : {0}", toolsVersion));
+ }
+
[Required]
public ITaskItem [] Projects {
get { return projects; }
@@ -170,12 +188,16 @@ namespace Microsoft.Build.Tasks {
set { buildInParallel = value; }
}
- Dictionary<string, string> SplitPropertiesToDictionary ()
+ public string ToolsVersion {
+ get; set;
+ }
+
+ SortedDictionary<string, string> SplitPropertiesToDictionary ()
{
if (properties == null)
return null;
- Dictionary<string, string> global_properties = new Dictionary<string, string> ();
+ var global_properties = new SortedDictionary<string, string> ();
foreach (string kvpair in properties) {
if (String.IsNullOrEmpty (kvpair))
continue;
diff --git a/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/ResolveAssemblyReference.cs b/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/ResolveAssemblyReference.cs
index 4f7665d7dde..ee39d771589 100644
--- a/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/ResolveAssemblyReference.cs
+++ b/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/ResolveAssemblyReference.cs
@@ -221,7 +221,8 @@ namespace Microsoft.Build.Tasks {
} else {
resolved = assembly_resolver.FindInDirectory (
item, spath,
- allowedAssemblyExtensions ?? default_assembly_extensions);
+ allowedAssemblyExtensions ?? default_assembly_extensions,
+ specific_version);
}
if (resolved != null)
@@ -239,10 +240,13 @@ namespace Microsoft.Build.Tasks {
specific_version = true;
string value = item.GetMetadata ("SpecificVersion");
if (String.IsNullOrEmpty (value)) {
- AssemblyName name = new AssemblyName (item.ItemSpec);
+ //AssemblyName name = new AssemblyName (item.ItemSpec);
// If SpecificVersion is not specified, then
// it is true if the Include is a strong name else false
- specific_version = assembly_resolver.IsStrongNamed (name);
+ //specific_version = assembly_resolver.IsStrongNamed (name);
+
+ // msbuild seems to just look for a ',' in the name :/
+ specific_version = item.ItemSpec.IndexOf (',') >= 0;
return true;
}
@@ -460,7 +464,7 @@ namespace Microsoft.Build.Tasks {
return false;
// match for full name
- if (AssemblyResolver.AssemblyNamesCompatible (key_aname, found_ref.AssemblyName, true))
+ if (AssemblyResolver.AssemblyNamesCompatible (key_aname, found_ref.AssemblyName, true, false))
// exact match, so its already there, dont add anything
return true;
diff --git a/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/Vbc.cs b/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/Vbc.cs
index 66c0889ce9c..52a8da8f978 100644
--- a/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/Vbc.cs
+++ b/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/Vbc.cs
@@ -31,6 +31,7 @@
using System;
using System.IO;
using System.Text;
+using System.Text.RegularExpressions;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
@@ -151,9 +152,53 @@ namespace Microsoft.Build.Tasks {
[MonoTODO]
protected override bool ValidateParameters ()
{
- throw new NotImplementedException ();
+ return true;
}
-
+
+ protected override void LogEventsFromTextOutput (string singleLine, MessageImportance importance)
+ {
+ singleLine = singleLine.Trim ();
+ if (singleLine.Length == 0)
+ return;
+
+ // When IncludeDebugInformation is true, prevents the debug symbols stats from braeking this.
+ if (singleLine.StartsWith ("WROTE SYMFILE") ||
+ singleLine.StartsWith ("OffsetTable") ||
+ singleLine.StartsWith ("Compilation succeeded") ||
+ singleLine.StartsWith ("Compilation failed"))
+ return;
+
+ Match match = ErrorRegex.Match (singleLine);
+ if (!match.Success) {
+ Log.LogMessage (importance, singleLine);
+ return;
+ }
+
+ string filename = match.Result ("${file}") ?? "";
+
+ string line = match.Result ("${line}");
+ int lineNumber = !string.IsNullOrEmpty (line) ? Int32.Parse (line) : 0;
+
+ string col = match.Result ("${column}");
+ int columnNumber = 0;
+ if (!string.IsNullOrEmpty (col))
+ columnNumber = col == "255+" ? -1 : Int32.Parse (col);
+
+ string category = match.Result ("${level}");
+ string code = match.Result ("${number}");
+ string text = match.Result ("${message}");
+
+ if (String.Compare (category, "warning", StringComparison.OrdinalIgnoreCase) == 0) {
+ Log.LogWarning (null, code, null, filename, lineNumber, columnNumber, -1,
+ -1, text, null);
+ } else if (String.Compare (category, "error", StringComparison.OrdinalIgnoreCase) == 0) {
+ Log.LogError (null, code, null, filename, lineNumber, columnNumber, -1,
+ -1, text, null);
+ } else {
+ Log.LogMessage (importance, singleLine);
+ }
+ }
+
[MonoTODO]
public string BaseAddress {
get { return (string) Bag ["BaseAddress"]; }
@@ -284,6 +329,20 @@ namespace Microsoft.Build.Tasks {
get { return (string) Bag ["WarningsNotAsErrors"]; }
set { Bag ["WarningsNotAsErrors"] = value; }
}
+
+ // from md's VBBindingCompilerServices.cs
+ //matches "/home/path/Default.aspx.vb (40,31) : Error VBNC30205: Expected end of statement."
+ //and "Error : VBNC99999: vbnc crashed nearby this location in the source code."
+ //and "Error : VBNC99999: Unexpected error: Object reference not set to an instance of an object"
+ static Regex errorRegex;
+ static Regex ErrorRegex {
+ get {
+ if (errorRegex == null)
+ errorRegex = new Regex (@"^\s*((?<file>.*)\s?\((?<line>\d*)(,(?<column>\d*))?\) : )?(?<level>\w+) :? ?(?<number>[^:]*): (?<message>.*)$", RegexOptions.Compiled | RegexOptions.ExplicitCapture);
+ return errorRegex;
+ }
+ }
+
}
}
diff --git a/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks_test.dll.sources b/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks_test.dll.sources
index 4cbc3917c3a..0b678d1795c 100644
--- a/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks_test.dll.sources
+++ b/mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks_test.dll.sources
@@ -4,7 +4,7 @@ Microsoft.Build.Tasks/AssignProjectConfigurationTest.cs
Microsoft.Build.Tasks/AssignTargetPathTest.cs
Microsoft.Build.Tasks/CombinePathTest.cs
Microsoft.Build.Tasks/CopyTest.cs
-Microsoft.Build.Tasks/Consts.cs
+../../Microsoft.Build.Engine/Test/Microsoft.Build.BuildEngine/Consts.cs
Microsoft.Build.Tasks/CreateCSharpManifestResourceNameTest.cs
Microsoft.Build.Tasks/CreateVisualBasicManifestResourceNameTest.cs
Microsoft.Build.Tasks/CreateItemTest.cs
diff --git a/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/AssignProjectConfigurationTest.cs b/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/AssignProjectConfigurationTest.cs
index 1458c999c6b..3673526ed70 100644
--- a/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/AssignProjectConfigurationTest.cs
+++ b/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/AssignProjectConfigurationTest.cs
@@ -136,7 +136,7 @@ namespace MonoTests.Microsoft.Build.Tasks
{
StringBuilder sb = new StringBuilder ();
sb.Append (@"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">");
- sb.Append ("\n<UsingTask TaskName=\"Microsoft.Build.Tasks.AssignProjectConfiguration\" AssemblyName=\"Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\" />\n");
+ sb.Append ("\n" + GetUsingTask ("AssignProjectConfiguration"));
sb.AppendFormat (@"<PropertyGroup>{0}</PropertyGroup>", CreateSolutionConfigurationProperty (guids, "Release|AnyCPU"));
sb.Append (CreateProjectReferencesItemGroup (project_ref_guids));
@@ -179,5 +179,11 @@ namespace MonoTests.Microsoft.Build.Tasks
sb.Append ("</ItemGroup>\n");
return sb.ToString ();
}
+
+ string GetUsingTask (string taskName)
+ {
+ return "<UsingTask TaskName='Microsoft.Build.Tasks." + taskName + "' AssemblyFile='" + Consts.GetTasksAsmPath () + "' />";
+ }
+
}
}
diff --git a/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/AssignTargetPathTest.cs b/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/AssignTargetPathTest.cs
index 0d7b99eb5a4..959c8991b77 100755
--- a/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/AssignTargetPathTest.cs
+++ b/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/AssignTargetPathTest.cs
@@ -150,7 +150,6 @@ namespace MonoTests.Microsoft.Build.Tasks
<Output TaskParameter=""AssignedFiles"" ItemName=""FooPath"" />
</AssignTargetPath>
</Target>
- <Import Project=""$(MSBuildBinPath)\Microsoft.Common.targets"" />
</Project>", rootFolder);
return sb.ToString();
diff --git a/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/ChangeLog b/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/ChangeLog
index 4a7e842d56f..73c326e93e6 100644
--- a/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/ChangeLog
+++ b/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/ChangeLog
@@ -1,3 +1,22 @@
+2010-04-06 Ankit Jain <jankit@novell.com>
+
+ * Consts.cs: Remove.
+ * AssignProjectConfigurationTest.cs:
+ * CreateCSharpManifestResourceNameTest.cs:
+ * CreateVisualBasicManifestResourceNameTest.cs:
+ * CreateItemTest.cs:
+ * FindAppConfigFileTest.cs:
+ * RemoveDuplicatesTest.cs:
+ * TaskBatchingTest.cs:
+ * WriteLinesToFileTest.cs:
+ Set the ToolsVersion to match the profile. Use the
+ full path to the tasks assembly for UsingTasks.
+
+2010-03-04 Ankit Jain <jankit@novell.com>
+
+ * AssignTargetPathTest.cs (CreateProjectString): Remove the
+ unnecessary import of ms.common.targets .
+
2010-02-06 Ankit Jain <jankit@novell.com>
* LCTest.cs: New.
diff --git a/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/CreateCSharpManifestResourceNameTest.cs b/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/CreateCSharpManifestResourceNameTest.cs
index 150104c662a..47f2b75e14f 100755
--- a/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/CreateCSharpManifestResourceNameTest.cs
+++ b/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/CreateCSharpManifestResourceNameTest.cs
@@ -235,9 +235,9 @@ namespace MonoTests.Microsoft.Build.Tasks
Project project = engine.CreateNewProject ();
TestMessageLogger logger = new TestMessageLogger ();
engine.RegisterLogger (logger);
- Console.WriteLine (projectText);
project.LoadXml (projectText);
if (!project.Build ("1")) {
+ Console.WriteLine (projectText);
logger.DumpMessages ();
Assert.Fail ("Build failed");
}
@@ -283,11 +283,16 @@ namespace MonoTests.Microsoft.Build.Tasks
sb.AppendFormat (" RootNamespace = \"{0}\"", rootNamespace);
sb.Append (">\n \t\t\t<Output TaskParameter=\"ManifestResourceNames\" ItemName=\"ResourceNames\" />\n");
sb.Append ("\t\t</CreateCSharpManifestResourceName>\n\t</Target>\n");
- sb.Append ("\t<UsingTask TaskName=\"Microsoft.Build.Tasks.CreateCSharpManifestResourceName\" " +
- "AssemblyName=\"Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\"/>\n");
+ sb.Append ("\t" + GetUsingTask ("CreateCSharpManifestResourceName"));
sb.Append ("</Project>");
return sb.ToString ();
}
+
+ string GetUsingTask (string taskName)
+ {
+ return "<UsingTask TaskName='Microsoft.Build.Tasks." + taskName + "' AssemblyFile='" + Consts.GetTasksAsmPath () + "' />";
+ }
+
}
}
diff --git a/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/CreateItemTest.cs b/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/CreateItemTest.cs
index d16c54572a1..cfe90118c38 100644
--- a/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/CreateItemTest.cs
+++ b/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/CreateItemTest.cs
@@ -252,6 +252,7 @@ namespace MonoTests.Microsoft.Build.Tasks {
}
+#if NET_3_5 || NET_4_0
[Test]
public void TestItemsWithWildcards () {
Engine engine = new Engine (Consts.BinPath);
@@ -274,7 +275,7 @@ namespace MonoTests.Microsoft.Build.Tasks {
};
string documentString = @"
- <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""3.5"">
+ <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" " + Consts.ToolsVersionString + @">
<PropertyGroup>
<WC>dir\**\*.dll</WC>
<ExWC>*\x*.dll</ExWC>
@@ -318,6 +319,7 @@ namespace MonoTests.Microsoft.Build.Tasks {
Directory.Delete (basedir, true);
}
}
+#endif
void CreateDirectoriesAndFiles (string basedir, string[] dirs, string[] files) {
foreach (string dir in dirs)
diff --git a/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/CreateVisualBasicManifestResourceNameTest.cs b/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/CreateVisualBasicManifestResourceNameTest.cs
index bb94c5c3af2..b5b4b18b87f 100644
--- a/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/CreateVisualBasicManifestResourceNameTest.cs
+++ b/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/CreateVisualBasicManifestResourceNameTest.cs
@@ -235,9 +235,9 @@ namespace MonoTests.Microsoft.Build.Tasks
Project project = engine.CreateNewProject ();
TestMessageLogger logger = new TestMessageLogger ();
engine.RegisterLogger (logger);
- Console.WriteLine (projectText);
project.LoadXml (projectText);
if (!project.Build ("1")) {
+ Console.WriteLine (projectText);
logger.DumpMessages ();
Assert.Fail ("Build failed");
}
@@ -283,11 +283,16 @@ namespace MonoTests.Microsoft.Build.Tasks
sb.AppendFormat (" RootNamespace = \"{0}\"", rootNamespace);
sb.Append (">\n \t\t\t<Output TaskParameter=\"ManifestResourceNames\" ItemName=\"ResourceNames\" />\n");
sb.Append ("\t\t</CreateVisualBasicManifestResourceName>\n\t</Target>\n");
- sb.Append ("\t<UsingTask TaskName=\"Microsoft.Build.Tasks.CreateVisualBasicManifestResourceName\" " +
- "AssemblyName=\"Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\"/>\n");
+ sb.Append ("\t" + GetUsingTask ("CreateVisualBasicManifestResourceName"));
sb.Append ("</Project>");
return sb.ToString ();
}
+
+ string GetUsingTask (string taskName)
+ {
+ return "<UsingTask TaskName='Microsoft.Build.Tasks." + taskName + "' AssemblyFile='" + Consts.GetTasksAsmPath () + "' />";
+ }
+
}
}
diff --git a/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/FindAppConfigFileTest.cs b/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/FindAppConfigFileTest.cs
index d6b9d0aa4d8..5aaa23086b9 100644
--- a/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/FindAppConfigFileTest.cs
+++ b/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/FindAppConfigFileTest.cs
@@ -25,6 +25,8 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#if NET_3_5
+
using System;
using System.Collections;
using Microsoft.Build.BuildEngine;
@@ -85,7 +87,7 @@ namespace MonoTests.Microsoft.Build.Tasks {
void CheckOutput (string[] primary_list, string[] secondary_list, string expected) {
StringBuilder sb = new StringBuilder ();
- sb.Append (@"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""3.5"">");
+ sb.Append (@"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" " + Consts.ToolsVersionString + ">");
sb.Append ("\t<ItemGroup>");
if (primary_list != null)
foreach (string s in primary_list)
@@ -124,4 +126,4 @@ namespace MonoTests.Microsoft.Build.Tasks {
}
}
}
-
+#endif
diff --git a/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/RemoveDuplicatesTest.cs b/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/RemoveDuplicatesTest.cs
index b4c17a8f371..6c1975c804c 100644
--- a/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/RemoveDuplicatesTest.cs
+++ b/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/RemoveDuplicatesTest.cs
@@ -44,7 +44,7 @@ namespace MonoTests.Microsoft.Build.Tasks
public void Test1 ()
{
string documentString = @"
- <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion='3.5'>
+ <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" " + Consts.ToolsVersionString + @">
<ItemGroup>
<Items Include='A'>
diff --git a/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/TaskBatchingTest.cs b/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/TaskBatchingTest.cs
index 6bfaae755e9..e854812b76b 100644
--- a/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/TaskBatchingTest.cs
+++ b/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/TaskBatchingTest.cs
@@ -40,6 +40,12 @@ namespace MonoTests.Microsoft.Build.Tasks
[TestFixture]
public class TaskBatchingTest
{
+ string projectHeader;
+ public TaskBatchingTest ()
+ {
+ projectHeader = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" " + Consts.ToolsVersionString + ">";
+ }
+
[Test]
public void Test1 ()
{
@@ -548,7 +554,7 @@ namespace MonoTests.Microsoft.Build.Tasks
// batching should happen only on basis of the task attributes,
// and not the resolved expression values
public void TestBatching1 () {
- string projectString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""3.5"">
+ string projectString = projectHeader + @"
<ItemGroup>
<item3 Include=""foo""/>
<item2 Include=""%(item3.Identity)""/>
@@ -584,7 +590,7 @@ namespace MonoTests.Microsoft.Build.Tasks
// batching should happen only on basis of the task attributes,
// and not the resolved expression values
public void TestConditionalBatching2 () {
- string projectString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""3.5"">
+ string projectString = projectHeader + @"
<ItemGroup>
<item2 Include=""%(item3.Identity)""/>
<item4 Include=""%(item2.Identity);@(item3)""/>
@@ -614,7 +620,7 @@ namespace MonoTests.Microsoft.Build.Tasks
[Test]
public void TestBatchingWithUnbatchedItems () {
- string projectString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""3.5"">
+ string projectString = projectHeader + @"
<ItemGroup>
<Item1 Include=""One""/>
<Item1 Include=""Two""/>
@@ -651,7 +657,7 @@ namespace MonoTests.Microsoft.Build.Tasks
[Test]
public void TestPropertiesWithBatchedReferences () {
- string projectString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""3.5"">
+ string projectString = projectHeader + @"
<ItemGroup>
<Item1 Include=""One""/>
<Item1 Include=""Two""/>
@@ -693,7 +699,7 @@ namespace MonoTests.Microsoft.Build.Tasks
[Test]
public void TestPropertiesWithDynamicItems () {
- string projectString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""3.5"">
+ string projectString = projectHeader + @"
<ItemGroup>
<Item1 Include=""One""/>
<Item1 Include=""Two""/>
@@ -748,7 +754,7 @@ namespace MonoTests.Microsoft.Build.Tasks
[Test]
public void TestTargetInvocationFromBatchedTask () {
- string projectString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""3.5"">
+ string projectString = projectHeader + @"
<ItemGroup>
<Item1 Include=""One""/>
<Item1 Include=""Two""/>
@@ -799,7 +805,7 @@ namespace MonoTests.Microsoft.Build.Tasks
[Test]
public void TestTargetInvocationFromBatchedTarget () {
- string projectString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""3.5"">
+ string projectString = projectHeader + @"
<ItemGroup>
<Item1 Include=""One""/>
<Item1 Include=""Two""/>
@@ -864,7 +870,7 @@ namespace MonoTests.Microsoft.Build.Tasks
[Test]
public void TestBatchingWithUnqualifiedMetadataReference () {
- string projectString = @"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion=""3.5"">
+ string projectString = projectHeader + @"
<ItemGroup>
<Item1 Include=""One""><Md>1</Md></Item1>
<Item1 Include=""Two""><Md>2</Md></Item1>
diff --git a/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/WriteLinesToFileTest.cs b/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/WriteLinesToFileTest.cs
index 62c03ac7e6b..82d4471a53a 100755
--- a/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/WriteLinesToFileTest.cs
+++ b/mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/WriteLinesToFileTest.cs
@@ -159,7 +159,7 @@ namespace MonoTests.Microsoft.Build.Tasks {
Project project;
StringBuilder sb = new StringBuilder ();
- sb.Append (@"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" ToolsVersion='3.5'>
+ sb.Append (@"<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"" " + Consts.ToolsVersionString + @">
<ItemGroup>
");
diff --git a/mcs/class/Microsoft.Build.Tasks/Test/test-config-file-net-3.5 b/mcs/class/Microsoft.Build.Tasks/Test/test-config-file-net-3.5
new file mode 100644
index 00000000000..7756bca8df1
--- /dev/null
+++ b/mcs/class/Microsoft.Build.Tasks/Test/test-config-file-net-3.5
@@ -0,0 +1,15 @@
+<?xml version ="1.0"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
+ <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="3.5.0.0"/>
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="Microsoft.Build.Engine" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
+ <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="3.5.0.0"/>
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/mcs/class/Microsoft.Build.Tasks/Test/test-config-file-net-4.0 b/mcs/class/Microsoft.Build.Tasks/Test/test-config-file-net-4.0
new file mode 100644
index 00000000000..3c78f3b4ec8
--- /dev/null
+++ b/mcs/class/Microsoft.Build.Tasks/Test/test-config-file-net-4.0
@@ -0,0 +1,15 @@
+<?xml version ="1.0"?>
+<configuration>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
+ <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="4.0.0.0"/>
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="Microsoft.Build.Engine" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
+ <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="4.0.0.0"/>
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
+</configuration>
diff --git a/mcs/class/Microsoft.Build.Utilities/ChangeLog b/mcs/class/Microsoft.Build.Utilities/ChangeLog
index d82c0037907..19ffbef5c9f 100644
--- a/mcs/class/Microsoft.Build.Utilities/ChangeLog
+++ b/mcs/class/Microsoft.Build.Utilities/ChangeLog
@@ -1,3 +1,10 @@
+2010-04-03 Ankit Jain <jankit@novell.com>
+
+ * Makefile: Import tools/xbuild/xbuild_targets.make, which copies
+ the target and tasks file in the correct place, to allow running
+ tests with different toolsversion.
+ Use the correct target assembly name for 4.0 profile.
+
2010-02-10 Ankit Jain <jankit@novell.com>
* Microsoft.Build.Utilities.dll.sources: Add ProcessStringDictionary.cs
diff --git a/mcs/class/Microsoft.Build.Utilities/Makefile b/mcs/class/Microsoft.Build.Utilities/Makefile
index bbfc0a9f1ae..a600ff9b67e 100644
--- a/mcs/class/Microsoft.Build.Utilities/Makefile
+++ b/mcs/class/Microsoft.Build.Utilities/Makefile
@@ -12,6 +12,10 @@ endif
ifeq (3.5, $(FRAMEWORK_VERSION))
LIBRARY_NAME = Microsoft.Build.Utilities.v3.5.dll
+else
+ifeq (4.0, $(FRAMEWORK_VERSION))
+LIBRARY_NAME = Microsoft.Build.Utilities.v4.0.dll
+endif
endif
LIB_MCS_FLAGS = \
@@ -21,4 +25,8 @@ LIB_MCS_FLAGS = \
TEST_MCS_FLAGS = /r:Microsoft.Build.Framework.dll
+export TESTING_MONO=a
+XBUILD_DIR=../../tools/xbuild
+include $(XBUILD_DIR)/xbuild_targets.make
+
include ../../build/library.make
diff --git a/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ChangeLog b/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ChangeLog
index d7f994b30d9..9b48a6ebad1 100644
--- a/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ChangeLog
+++ b/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ChangeLog
@@ -1,3 +1,24 @@
+2010-04-10 Ankit Jain <jankit@novell.com>
+
+ * ReservedNameUtils.cs (GetReservedMetadata): Handle empty item.
+
+2010-04-08 Ankit Jain <jankit@novell.com>
+
+ * ToolTask.cs: Use regex to parse output. Regex is from monodevelop.
+
+2010-04-08 Ankit Jain <jankit@novell.com>
+
+ * ToolTask.cs (ExecuteTool): Check that the tool exists.
+
+2010-04-03 Ankit Jain <jankit@novell.com>
+
+ * TargetDotNetFrameworkVersion.cs: Add Version40 .
+ * Task.cs (BuildEngine2): New.
+ * ToolLocationHelper.cs: Use class/lib/net_* as the path
+ for the assemblies and targets when running tests.
+ Environment variable TESTING_MONO is set for testing.
+ This allows a 4.0 xbuild to build 2.0/3.5 projects.
+
2010-02-19 Ankit Jain <jankit@novell.com>
* TaskItem.cs: Track api changes.
diff --git a/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/TargetDotNetFrameworkVersion.cs b/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/TargetDotNetFrameworkVersion.cs
index 451e40ef145..60cd2dba3dc 100644
--- a/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/TargetDotNetFrameworkVersion.cs
+++ b/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/TargetDotNetFrameworkVersion.cs
@@ -37,7 +37,12 @@ namespace Microsoft.Build.Utilities
Version20,
Version30,
Version35,
+#if NET_4_0
+ Version40,
+ VersionLatest = Version40
+#else
VersionLatest = Version35
+#endif
}
}
diff --git a/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/Task.cs b/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/Task.cs
index 62276342051..a529e1fafab 100644
--- a/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/Task.cs
+++ b/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/Task.cs
@@ -70,6 +70,10 @@ namespace Microsoft.Build.Utilities
}
}
+ public IBuildEngine2 BuildEngine2 {
+ get { return buildEngine as IBuildEngine2; }
+ }
+
protected string HelpKeywordPrefix {
get {
return helpKeywordPrefix;
diff --git a/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolLocationHelper.cs b/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolLocationHelper.cs
index 3c132076022..a6c807cfbdf 100644
--- a/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolLocationHelper.cs
+++ b/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolLocationHelper.cs
@@ -50,13 +50,24 @@ namespace Microsoft.Build.Utilities
t2 = t1.Parent;
lib_mono_dir = t2.FullName;
+ if (Environment.GetEnvironmentVariable ("TESTING_MONO") != null) {
+ mono_dir = new string [] {
+ Path.Combine (lib_mono_dir, "net_1_0"),
+ Path.Combine (lib_mono_dir, "net_2_0"),
+ Path.Combine (lib_mono_dir, "net_2_0"),
+ Path.Combine (lib_mono_dir, "net_3_5"),
+ Path.Combine (lib_mono_dir, "net_4_0")
+ };
+ } else {
+ mono_dir = new string [] {
+ Path.Combine (lib_mono_dir, "1.0"),
+ Path.Combine (lib_mono_dir, "2.0"),
+ Path.Combine (lib_mono_dir, "2.0"),
+ Path.Combine (lib_mono_dir, "3.5"),
+ Path.Combine (lib_mono_dir, "4.0")
+ };
+ }
- mono_dir = new string [] {
- Path.Combine (lib_mono_dir, "1.0"),
- Path.Combine (lib_mono_dir, "2.0"),
- Path.Combine (lib_mono_dir, "2.0"),
- Path.Combine (lib_mono_dir, "3.5")
- };
}
[MonoTODO]
diff --git a/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolTask.cs b/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolTask.cs
index 2af0265325b..1a9247e2d0d 100644
--- a/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolTask.cs
+++ b/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolTask.cs
@@ -56,8 +56,6 @@ namespace Microsoft.Build.Utilities
StringBuilder toolOutput;
bool typeLoadException;
- static Regex regex;
-
protected ToolTask ()
: this (null, null)
{
@@ -81,19 +79,6 @@ namespace Microsoft.Build.Utilities
this.environmentOverride = new SCS.ProcessStringDictionary ();
}
- static ToolTask ()
- {
- regex = new Regex (
- @"^\s*"
- + @"(((?<ORIGIN>(((\d+>)?[a-zA-Z]?:[^:]*)|([^:]*))):)"
- + "|())"
- + "(?<SUBCATEGORY>(()|([^:]*? )))"
- + "(?<CATEGORY>(error|warning)) "
- + "(?<CODE>[^:]*):"
- + "(?<TEXT>.*)$",
- RegexOptions.IgnoreCase);
- }
-
[MonoTODO]
protected virtual bool CallHostObjectToExecute ()
{
@@ -233,80 +218,33 @@ namespace Microsoft.Build.Utilities
singleLine.StartsWith ("Compilation failed"))
return;
- string filename, origin, category, code, subcategory, text;
- int lineNumber, columnNumber, endLineNumber, endColumnNumber;
-
- Match m = regex.Match (singleLine);
- origin = m.Groups [regex.GroupNumberFromName ("ORIGIN")].Value;
- category = m.Groups [regex.GroupNumberFromName ("CATEGORY")].Value;
- code = m.Groups [regex.GroupNumberFromName ("CODE")].Value;
- subcategory = m.Groups [regex.GroupNumberFromName ("SUBCATEGORY")].Value;
- text = m.Groups [regex.GroupNumberFromName ("TEXT")].Value;
-
- ParseOrigin (origin, out filename, out lineNumber, out columnNumber, out endLineNumber, out endColumnNumber);
-
- if (category == "warning") {
- Log.LogWarning (subcategory, code, null, filename, lineNumber, columnNumber, endLineNumber,
- endColumnNumber, text, null);
- } else if (category == "error") {
- Log.LogError (subcategory, code, null, filename, lineNumber, columnNumber, endLineNumber,
- endColumnNumber, text, null);
- } else {
+ Match match = CscErrorRegex.Match (singleLine);
+ if (!match.Success) {
Log.LogMessage (importance, singleLine);
+ return;
}
- }
-
- private void ParseOrigin (string origin, out string filename,
- out int lineNumber, out int columnNumber,
- out int endLineNumber, out int endColumnNumber)
- {
- int lParen;
- string[] temp;
- string[] left, right;
-
- if (origin.IndexOf ('(') != -1 ) {
- lParen = origin.IndexOf ('(');
- filename = origin.Substring (0, lParen);
- temp = origin.Substring (lParen + 1, origin.Length - lParen - 2).Split (',');
- if (temp.Length == 1) {
- left = temp [0].Split ('-');
- if (left.Length == 1) {
- lineNumber = Int32.Parse (left [0]);
- columnNumber = 0;
- endLineNumber = 0;
- endColumnNumber = 0;
- } else if (left.Length == 2) {
- lineNumber = Int32.Parse (left [0]);
- columnNumber = 0;
- endLineNumber = Int32.Parse (left [1]);
- endColumnNumber = 0;
- } else
- throw new Exception ("Invalid line/column format.");
- } else if (temp.Length == 2) {
- right = temp [1].Split ('-');
- lineNumber = Int32.Parse (temp [0]);
- endLineNumber = 0;
- if (right.Length == 1) {
- columnNumber = Int32.Parse (right [0]);
- endColumnNumber = 0;
- } else if (right.Length == 2) {
- columnNumber = Int32.Parse (right [0]);
- endColumnNumber = Int32.Parse (right [0]);
- } else
- throw new Exception ("Invalid line/column format.");
- } else if (temp.Length == 4) {
- lineNumber = Int32.Parse (temp [0]);
- endLineNumber = Int32.Parse (temp [2]);
- columnNumber = Int32.Parse (temp [1]);
- endColumnNumber = Int32.Parse (temp [3]);
- } else
- throw new Exception ("Invalid line/column format.");
+
+ string filename = match.Result ("${file}") ?? "";
+ string line = match.Result ("${line}");
+ int lineNumber = !string.IsNullOrEmpty (line) ? Int32.Parse (line) : 0;
+
+ string col = match.Result ("${column}");
+ int columnNumber = 0;
+ if (!string.IsNullOrEmpty (col))
+ columnNumber = col == "255+" ? -1 : Int32.Parse (col);
+
+ string category = match.Result ("${level}");
+ string code = match.Result ("${number}");
+ string text = match.Result ("${message}");
+
+ if (String.Compare (category, "warning", StringComparison.OrdinalIgnoreCase) == 0) {
+ Log.LogWarning (null, code, null, filename, lineNumber, columnNumber, -1,
+ -1, text, null);
+ } else if (String.Compare (category, "error", StringComparison.OrdinalIgnoreCase) == 0) {
+ Log.LogError (null, code, null, filename, lineNumber, columnNumber, -1,
+ -1, text, null);
} else {
- filename = origin;
- lineNumber = 0;
- columnNumber = 0;
- endLineNumber = 0;
- endColumnNumber = 0;
+ Log.LogMessage (importance, singleLine);
}
}
@@ -447,6 +385,17 @@ namespace Microsoft.Build.Utilities
toolPath = value;
}
}
+
+ // Snatched from our codedom code, with some changes to make it compatible with csc
+ // (the line+column group is optional is csc)
+ static Regex errorRegex;
+ static Regex CscErrorRegex {
+ get {
+ if (errorRegex == null)
+ errorRegex = new Regex (@"^(\s*(?<file>[^\(]+)(\((?<line>\d*)(,(?<column>\d*[\+]*))?\))?:\s+)*(?<level>\w+)\s+(?<number>.*\d):\s*(?<message>.*)", RegexOptions.Compiled | RegexOptions.ExplicitCapture);
+ return errorRegex;
+ }
+ }
}
}
diff --git a/mcs/class/Microsoft.Build.Utilities/Mono.XBuild.Utilities/ReservedNameUtils.cs b/mcs/class/Microsoft.Build.Utilities/Mono.XBuild.Utilities/ReservedNameUtils.cs
index 49f489948e7..e8379f00be0 100644
--- a/mcs/class/Microsoft.Build.Utilities/Mono.XBuild.Utilities/ReservedNameUtils.cs
+++ b/mcs/class/Microsoft.Build.Utilities/Mono.XBuild.Utilities/ReservedNameUtils.cs
@@ -72,6 +72,9 @@ namespace Mono.XBuild.Utilities {
{
if (metadataName == null)
throw new ArgumentNullException ();
+
+ if (String.IsNullOrEmpty (itemSpec))
+ return String.Empty;
switch (metadataName.ToLower ()) {
case "fullpath":