Valid TaskActions are:

Add (Required: CategoryName, CounterList, CategoryHelp Optional: MultiInstance)

CheckCategoryExists (Required: CategoryName Optional: MachineName)

CheckCounterExists (Required: CategoryName, CounterName Optional: MachineName)

GetValue (Required: CategoryName, CounterName Output: Value, MachineName)

Remove (Required: CategoryName)

Remote Execution Support: Partial

Namespace: MSBuild.ExtensionPack.Computer
Assembly: MSBuild.ExtensionPack (in MSBuild.ExtensionPack.dll) Version: 3.5.0.0

Examples

Xml Copy imageCopy
<Project ToolsVersion="3.5" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <TPath>$(MSBuildProjectDirectory)\..\MSBuild.ExtensionPack.tasks</TPath>
        <TPath Condition="Exists('$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks')">$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks</TPath>
    </PropertyGroup>
    <Import Project="$(TPath)"/>
    <Target Name="Default">
        <ItemGroup>
            <!-- Configure some perf counters -->
            <CounterList Include="foobar.A">
                <CounterName>ACounter</CounterName>
                <CounterHelp>A Custom Counter</CounterHelp>
                <CounterType>CounterTimer</CounterType>
            </CounterList>
            <CounterList Include="foobar.A">
                <CounterName>AnotherCounter</CounterName>
                <CounterHelp>Another Custom Counter</CounterHelp>
                <CounterType>CounterTimer</CounterType>
            </CounterList>
        </ItemGroup>
        <!-- Add a Performance Counter -->
        <MSBuild.ExtensionPack.Computer.PerformanceCounters TaskAction="Add" CategoryName="YourCustomCategory" CategoryHelp="This is a custom performance counter category" CounterList="@(CounterList)" MultiInstance="true" />
        <!-- Check whether a Category Exists -->
        <MSBuild.ExtensionPack.Computer.PerformanceCounters TaskAction="CheckCategoryExists" CategoryName="aYourCustomCategory">
            <Output TaskParameter="Exists" PropertyName="DoesExist"/>
        </MSBuild.ExtensionPack.Computer.PerformanceCounters>
        <Message Text="aYourCustomCategory - $(DoesExist)"/>
        <!-- Check whether a Counter Exists -->
        <MSBuild.ExtensionPack.Computer.PerformanceCounters TaskAction="CheckCounterExists" CategoryName="aYourCustomCategory" CounterName="AnotherCounter">
            <Output TaskParameter="Exists" PropertyName="DoesExist"/>
        </MSBuild.ExtensionPack.Computer.PerformanceCounters>
        <Message Text="AnotherCounter - $(DoesExist)"/>
        <!-- Remove a Performance Counter -->
        <MSBuild.ExtensionPack.Computer.PerformanceCounters TaskAction="Remove" CategoryName="YourCustomCategory"/>
        <!-- Get a Performance Counter value-->
        <MSBuild.ExtensionPack.Computer.PerformanceCounters TaskAction="GetValue" CategoryName="Memory" CounterName="Available MBytes">
            <Output PropertyName="TheValue" TaskParameter="Value"/>
        </MSBuild.ExtensionPack.Computer.PerformanceCounters>
        <Message Text="Available MBytes: $(TheValue)"/>
    </Target>
</Project>

Inheritance Hierarchy

System..::..Object
  Microsoft.Build.Utilities..::..Task
    MSBuild.ExtensionPack..::..BaseTask
      MSBuild.ExtensionPack.Computer..::..PerformanceCounters

See Also