This documentation is archived and is not being maintained.

TaskItem Class

Defines a single item of the project as it is passed into a task.


Namespace:  Microsoft.Build.Utilities
Assembly:  Microsoft.Build.Utilities.v4.0 (in Microsoft.Build.Utilities.v4.0.dll)

public sealed class TaskItem : MarshalByRefObject, 
	ITaskItem2, ITaskItem

The TaskItem type exposes the following members.

Public methodTaskItem()Initializes a new instance of the TaskItem class.
Public methodTaskItem(ITaskItem)Initializes a new instance of the TaskItem class using the specified source ITaskItem.
Public methodTaskItem(String)Initializes a new instance of the TaskItem class using the specified item-specification string.
Public methodTaskItem(String, IDictionary)Initializes a new instance of the TaskItem class using the specified item-specification string and its metadata.

Public propertyItemSpecGets or sets the item specification.
Public propertyMetadataCountGets the number of metadata set on the item.
Public propertyMetadataNamesGets the names of all the metadata on the item.

Public methodCloneCustomMetadataClones the collection of custom metadata for the item specification.
Public methodCopyMetadataToCopies the item-specification metadata to the specified destination task item.
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodGetMetadataRetrieves the specified metadata on the item.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeLifetimeServiceWhen overridden in a derived class, gives task items infinite lease time. (Overrides MarshalByRefObject.InitializeLifetimeService().)
Protected methodMemberwiseClone()Creates a shallow copy of the current Object. (Inherited from Object.)
Protected methodMemberwiseClone(Boolean)Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.)
Public methodRemoveMetadataRemoves the specified metadata on the item.
Public methodSetMetadataSets or modifies the value of the specified metadata on the item.
Public methodToStringGets the item specification. (Overrides Object.ToString().)

Public operatorStatic memberExplicit(TaskItem to String)Allows an explicit type cast from a TaskItem to a String, and returns the ItemSpec for that item.

Explicit interface implemetationPrivate methodITaskItem2.CloneCustomMetadataEscapedITaskItem2 implementation which returns a clone of the metadata on this object. Values returned are in their original escaped form.
Explicit interface implemetationPrivate propertyITaskItem2.EvaluatedIncludeEscapedITaskItem2 implementation which gets or sets the item include value. For disk-based items this would be the file path.
Explicit interface implemetationPrivate methodITaskItem2.GetMetadataValueEscapedITaskItem2 implementation which allows the values of metadata on the item to be queried.
Explicit interface implemetationPrivate methodITaskItem2.SetMetadataValueLiteralITaskItem2 implementation which allows a piece of custom metadata to be set on the item. Assumes that the value passed in is unescaped, and escapes the value as necessary in order to maintain its value.

TaskItem objects do not exactly correspond to item elements in project files. If they did, then tasks would have access to data that was not explicitly passed into the task through the project file. This is not a security issue, but rather an issue with project file clarity and transparency.

This class has to be sealed since the build engine instantiates its own copy of this type. If a third party were to extend this class, then the build engine will yield an undesired behavior.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.