Note that there are some explanatory texts on larger screens.

plurals
  1. PORead attributes of MSBuild custom tasks via events in the Logger
    text
    copied!<p>I am trying to write a MSBuild logger module which logs information when receiving <code>TaskStarted</code> events about the Task and its parameters.</p> <p>The build is run with the command:</p> <pre><code>MSBuild.exe /logger:MyLogger.dll build.xml </code></pre> <p>Within the build.xml is a sequence of tasks, most of which have been custom written to compile a (C++ or C#) solution, and are accessed with the following custom Task:</p> <pre><code>&lt;DoCompile Desc="Building MyProject 1" Param1="$(Param1Value)" /&gt; &lt;DoCompile Desc="Building MyProject 2" Param1="$(Param1Value)" /&gt; &lt;!-- etc --&gt; </code></pre> <p>The custom build task <code>DoCompile</code> is defined as:</p> <pre><code>public class DoCompile : Microsoft.Build.Utilities.Task { [Required] public string Description { set { _description = value; } } // ... more code here ... } </code></pre> <p>Whilst the build is running, as each task starts, the logger module receives <code>IEventSource.TaskStarted</code> events, subscribed to as follows:</p> <pre><code>public class MyLogger : Microsoft.Build.Utilities.Logger { public override void Initialize(Microsoft.Build.Framework.IEventSource eventSource) { eventSource.TaskStarted += taskStarted; } private void taskStarted(object sender, Microsoft.Build.Framework.TaskStartedEventArgs e) { // write e.TaskName, attributes and e.Timestamp to log file } } </code></pre> <p>The problem I have is that in the <code>taskStarted()</code> method above, I want to be able to access the attributes of the task for which the event was fired. I only have access to the logger code and cannot change either the build.xml or the custom build tasks.</p> <p>Can anyone suggest a way I can do this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload