Delen via


TaskItem Class

Definition

This class represents a single item of the project, as it is passed into a task. TaskItems do not exactly correspond to item elements in project files, because then tasks would have access to data that wasn't explicitly passed into the task via the project file. It's not a security issue, but more just an issue with project file clarity and transparency.

Note: This class has to be sealed. It has to be sealed because the engine instantiates it's own copy of this type and thus if someone were to extend it, they would not get the desired behavior from the engine.

public ref class TaskItem sealed : MarshalByRefObject, Microsoft::Build::Framework::ITaskItem2
public ref class TaskItem sealed : Microsoft::Build::Framework::ITaskItem2
public ref class TaskItem sealed : MarshalByRefObject, Microsoft::Build::Framework::ITaskItem
public sealed class TaskItem : MarshalByRefObject, Microsoft.Build.Framework.ITaskItem2
public sealed class TaskItem : Microsoft.Build.Framework.ITaskItem2
public sealed class TaskItem : MarshalByRefObject, Microsoft.Build.Framework.ITaskItem
type TaskItem = class
    inherit MarshalByRefObject
    interface ITaskItem
    interface ITaskItem2
type TaskItem = class
    interface ITaskItem
    interface ITaskItem2
type TaskItem = class
    inherit MarshalByRefObject
    interface ITaskItem2
    interface ITaskItem
type TaskItem = class
    interface ITaskItem2
    interface ITaskItem
type TaskItem = class
    inherit MarshalByRefObject
    interface ITaskItem
Public NotInheritable Class TaskItem
Inherits MarshalByRefObject
Implements ITaskItem2
Public NotInheritable Class TaskItem
Implements ITaskItem2
Public NotInheritable Class TaskItem
Inherits MarshalByRefObject
Implements ITaskItem
Inheritance
Inheritance
TaskItem
Implements

Remarks

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.

Constructors

TaskItem()

Default constructor -- we need it so this type is COM-createable.

TaskItem(ITaskItem)

This constructor creates a new TaskItem, using the given ITaskItem.

TaskItem(String, IDictionary)

This constructor creates a new TaskItem, using the given item spec and metadata.

TaskItem(String)

This constructor creates a new task item, given the item spec.

Properties

ItemSpec

Gets or sets the item-spec.

MetadataCount

Gets the number of metadata set on the item.

MetadataNames

Gets the names of all the item's metadata.

Methods

CloneCustomMetadata()

Get the collection of custom metadata. This does not include built-in metadata.

CopyMetadataTo(ITaskItem)

Copy the metadata (but not the ItemSpec) to destinationItem. If a particular metadata already exists on the destination item, then it is not overwritten -- the original value wins.

GetMetadata(String)

Retrieves one of the arbitrary metadata on the item. If not found, returns empty string.

InitializeLifetimeService()

Overridden to give this class infinite lease time. Otherwise we end up with a limited lease (5 minutes I think) and instances can expire if they take long time processing.

RemoveMetadata(String)

Removes one of the arbitrary metadata on the item.

SetMetadata(String, String)

Sets one of the arbitrary metadata on the item.

ToString()

Gets the item-spec.

Operators

Explicit(TaskItem to String)

This allows an explicit typecast from a "TaskItem" to a "string", returning the escaped ItemSpec for this item.

Explicit Interface Implementations

ITaskItem2.CloneCustomMetadataEscaped()

ITaskItem2 implementation which returns a clone of the metadata on this object. Values returned are in their original escaped form.

ITaskItem2.EvaluatedIncludeEscaped

Gets or sets the escaped include, or "name", for the item.

ITaskItem2.GetMetadataValueEscaped(String)

Returns the escaped value of the metadata with the specified key.

ITaskItem2.SetMetadataValueLiteral(String, String)

Sets the escaped value of the metadata with the specified name.

Applies to