msbuild ITaskItem output

2.3k Views Asked by At

I'm trying to use MSBuild.ExtensionPack.Web.Iis7AppPool task with GetInfo task action. This task's output parameter is SiteInfo property, which its type is ITaskItem. This is a propery, not a collection.

How can I access the SiteInfo metadata? I can access with $, but then all I can get is the web site name. I tried to use %(SiteInfo.) with no success.

1

There are 1 best solutions below

0
On BEST ANSWER

If the output parameter is an ITaskItem and you want to access the metadata then you need to assign it to an ItemGroup instead of a Property.

 <Target Name="Test">

    <MSBuild.ExtensionPack.Web.Iis7AppPool
      TaskAction="GetInfo"
      Name="DefaultAppPool">

      <Output TaskParameter="AppPoolInfo" ItemName="PoolInfo"  />
    </MSBuild.ExtensionPack.Web.Iis7AppPool>

    <Message Text="AppPool info = [@(PoolInfo)]" />
    <Message Text="AppPool MaxProcesses = [%(PoolInfo.MaxProcesses)]" />

    <MSBuild.ExtensionPack.Web.Iis7WebSite
      TaskAction="GetInfo"
      Name="Default Web Site">

      <Output TaskParameter="SiteId" PropertyName="WebId"  />
      <Output TaskParameter="SiteInfo" ItemName="WebInfo"  />
    </MSBuild.ExtensionPack.Web.Iis7WebSite>

    <Message Text="WebSite id = [$(WebId)]" />
    <Message Text="WebSite app pool = [%(WebInfo.ApplicationPoolName)]" />

  </Target>