PerformanceCounters Class | MSBuild Extension Pack Help 4.0.12.0 |
Valid TaskActions are:
Add (Required: CategoryName, CounterList, CategoryHelp Optional: MultiInstance, KeepExistingCounters)
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
Inheritance Hierarchy
MSBuild.ExtensionPackBaseTask
MSBuild.ExtensionPack.ComputerPerformanceCounters
Namespace: MSBuild.ExtensionPack.Computer
Assembly: MSBuild.ExtensionPack (in MSBuild.ExtensionPack.dll) Version: 4.0.0.0
The PerformanceCounters type exposes the following members.
Constructors
Name | Description | |
---|---|---|
PerformanceCounters |
Properties
Name | Description | |
---|---|---|
CategoryHelp |
Sets the description of the custom category.
| |
CategoryName |
Sets the CategoryName
| |
CounterList |
Sets the TaskItem[] that specifies the counters to create as part of the new category.
| |
CounterName |
Sets the name of the counter.
| |
Exists |
Gets whether the item exists
| |
KeepExistingCounters |
Sets a value whether existing performance counters of the given category should be preserved when adding new ones.
| |
MultiInstance |
Sets a value indicating whether to create a multiple instance performance counter. Default is false
| |
Value |
Gets the value of the counter
|
Examples
<Project ToolsVersion="4.0" 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>
See Also