فهرست منبع

2007-02-22 Marek Sieradzki <[email protected]>

        * BuildEngine.cs (BuildProjectFile): Don't crash on null
        globalProperties.

	* Target.cs: Add Outputs property.


svn path=/trunk/mcs/; revision=73294
Marek Sieradzki 19 سال پیش
والد
کامیت
ecefc7eae3

+ 4 - 3
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/BuildEngine.cs

@@ -59,8 +59,9 @@ namespace Microsoft.Build.BuildEngine {
 				       IDictionary targetOutputs)
 		{
 			BuildPropertyGroup bpg = new BuildPropertyGroup ();
-			foreach (DictionaryEntry de in globalProperties)
-				bpg.AddNewProperty ((string) de.Key, (string) de.Value);
+			if (globalProperties != null)
+				foreach (DictionaryEntry de in globalProperties)
+					bpg.AddNewProperty ((string) de.Key, (string) de.Value);
 			return engine.BuildProjectFile (projectFileName,
 				targetNames, bpg, targetOutputs);
 		}
@@ -108,4 +109,4 @@ namespace Microsoft.Build.BuildEngine {
 	}
 }
 
-#endif
+#endif

+ 7 - 0
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog

@@ -1,3 +1,10 @@
+2007-02-22  Marek Sieradzki  <[email protected]>
+
+	* BuildEngine.cs (BuildProjectFile): Don't crash on null
+	globalProperties.
+
+	* Target.cs: Add Outputs property.
+
 2007-02-20  Marek Sieradzki  <[email protected]>
 
 	* Target.cs (Build): Split to GetDependencies () and BuildDependencies

+ 22 - 3
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Target.cs

@@ -32,6 +32,7 @@ using System.Collections;
 using System.Collections.Generic;
 using System.Xml;
 using Microsoft.Build.Framework;
+using Microsoft.Build.Utilities;
 
 namespace Microsoft.Build.BuildEngine {
 	public class Target : IEnumerable {
@@ -127,7 +128,7 @@ namespace Microsoft.Build.BuildEngine {
 
 				buildState = BuildState.Finished;
 			// FIXME: log it 
-			} catch (Exception e) {
+			} catch (Exception) {
 				return false;
 			}
 
@@ -220,7 +221,7 @@ namespace Microsoft.Build.BuildEngine {
 		{
 			TargetStartedEventArgs tsea;
 			string projectFile = project.FullFileName;
-			tsea = new TargetStartedEventArgs ("Target " + name + " started.", null, name, projectFile, null);
+			tsea = new TargetStartedEventArgs (String.Format ("Target {0} started.", name), null, name, projectFile, null);
 			engine.EventSource.FireTargetStarted (this, tsea);
 		}
 		
@@ -228,7 +229,7 @@ namespace Microsoft.Build.BuildEngine {
 		{
 			TargetFinishedEventArgs tfea;
 			string projectFile = project.FullFileName;
-			tfea = new TargetFinishedEventArgs ("Target " + name + " finished.", null, name, projectFile, null, succeeded);
+			tfea = new TargetFinishedEventArgs (String.Format ("Target {0} finished.", name), null, name, projectFile, null, succeeded);
 			engine.EventSource.FireTargetFinished (this, tfea);
 		}
 	
@@ -257,6 +258,24 @@ namespace Microsoft.Build.BuildEngine {
 		internal BuildState BuildState {
 			get { return buildState; }
 		}
+
+		// FIXME: implement batching
+		internal ITaskItem [] Outputs {
+			get {
+				string outputs = targetElement.GetAttribute ("Outputs");
+				if (outputs == String.Empty)
+					return new ITaskItem [0];
+
+				Expression e = new Expression ();
+				e.Parse (outputs, true);
+
+				string [] outputFiles = (string []) e.ConvertTo (project, typeof (string []));
+				ITaskItem [] outputItems = new ITaskItem [outputFiles.Length];
+				for (int i = 0; i < outputFiles.Length; i++)
+					outputItems [i] = new TaskItem (outputFiles [i]);
+				return outputItems;
+			}
+		}
 	}
 	
 	internal enum BuildState {