title: How do I access ITaskItem meta data from with my MSBuild script?
body: <p>I have a custom Build task that returns ITaskTem[] as output to my build script. I cannot find an documentation/examples on how I can access these values from with in my MSBuild script.</p>
  
  <p>My Execute method calls this private method which returns the array. I would like to be able to iterate through the Output and get both the TaskItem ItemSpec and the "Message" metadata item. How can I do this?</p>
  
  <pre><code>[Output]
      public ITaskItem[] FailedTestsResults { get; set; }
  </code></pre>
  
  <p>...</p>
  
  <pre><code> private ITaskItem[] GetFailedTests(TestResultsSummary testResultsSummary)
      {          
         IList&lt;TestResult&gt; testList = testResultsSummary.Tests.ToList();
         IEnumerable&lt;TestResult&gt; failedTests = testList.Where(x =&gt; !x.Passed);
          IList&lt;ITaskItem&gt; failedTestsTaskItems = new List&lt;ITaskItem&gt;();
          foreach (var failedTest in failedTests)
          {
  
                  //test encountered enexpected error.
                  ITaskItem failTestItem = new TaskItem(failedTest.TestName);
                  failTestItem.SetMetadata("Message", failedTest.Message);
                  failedTestsTaskItems.Add(failTestItem);
          }
          return (ITaskItem[]) failedTestsTaskItems.ToArray();
      }
  </code></pre>