TaskItem Class

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

MSBuild is now included in Visual Studio instead of the .NET Framework. You can use MSBuild 12.0 side-by-side with versions previously deployed with the .NET Framework.For more information, see What's New in MSBuild 12.0.

Inheritance Hierarchy

System.Object
  System.MarshalByRefObject
    Microsoft.Build.Utilities.TaskItem

Namespace:  Microsoft.Build.Utilities
Assembly:  Microsoft.Build.Utilities.Core (in Microsoft.Build.Utilities.Core.dll)

Syntax

'Declaration
Public NotInheritable Class TaskItem _
    Inherits MarshalByRefObject _
    Implements ITaskItem, ITaskItem2
public sealed class TaskItem : MarshalByRefObject, 
    ITaskItem, ITaskItem2
public ref class TaskItem sealed : public MarshalByRefObject, 
    ITaskItem, ITaskItem2
[<Sealed>]
type TaskItem =  
    class 
        inherit MarshalByRefObject 
        interface ITaskItem 
        interface ITaskItem2 
    end
public final class TaskItem extends MarshalByRefObject implements ITaskItem, ITaskItem2

The TaskItem type exposes the following members.

Constructors

  Name Description
Public method TaskItem() Initializes a new instance of the TaskItem class.MSBuild is now included in Visual Studio instead of the .NET Framework. You can use MSBuild 12.0 side-by-side with versions previously deployed with the .NET Framework.For more information, see What's New in MSBuild 12.0.
Public method TaskItem(String) Initializes a new instance of the TaskItem class using the specified item-specification string.MSBuild is now included in Visual Studio instead of the .NET Framework. You can use MSBuild 12.0 side-by-side with versions previously deployed with the .NET Framework.For more information, see What's New in MSBuild 12.0.
Public method TaskItem(ITaskItem) Initializes a new instance of the TaskItem class using the specified source ITaskItem.MSBuild is now included in Visual Studio instead of the .NET Framework. You can use MSBuild 12.0 side-by-side with versions previously deployed with the .NET Framework.For more information, see What's New in MSBuild 12.0.
Public method TaskItem(String, IDictionary) Initializes a new instance of the TaskItem class using the specified item-specification string and its metadata.MSBuild is now included in Visual Studio instead of the .NET Framework. You can use MSBuild 12.0 side-by-side with versions previously deployed with the .NET Framework.For more information, see What's New in MSBuild 12.0.

Top

Properties

  Name Description
Public property ItemSpec Gets or sets the item specification.MSBuild is now included in Visual Studio instead of the .NET Framework. You can use MSBuild 12.0 side-by-side with versions previously deployed with the .NET Framework.For more information, see What's New in MSBuild 12.0.
Public property MetadataCount Gets the number of metadata set on the item.MSBuild is now included in Visual Studio instead of the .NET Framework. You can use MSBuild 12.0 side-by-side with versions previously deployed with the .NET Framework.For more information, see What's New in MSBuild 12.0.
Public property MetadataNames Gets the names of all the metadata on the item.MSBuild is now included in Visual Studio instead of the .NET Framework. You can use MSBuild 12.0 side-by-side with versions previously deployed with the .NET Framework.For more information, see What's New in MSBuild 12.0.

Top

Methods

  Name Description
Public method CloneCustomMetadata Clones the collection of custom metadata for the item specification.MSBuild is now included in Visual Studio instead of the .NET Framework. You can use MSBuild 12.0 side-by-side with versions previously deployed with the .NET Framework.For more information, see What's New in MSBuild 12.0.
Public method CopyMetadataTo Copies the item-specification metadata to the specified destination task item.MSBuild is now included in Visual Studio instead of the .NET Framework. You can use MSBuild 12.0 side-by-side with versions previously deployed with the .NET Framework.For more information, see What's New in MSBuild 12.0.
Public method CreateObjRef Security Critical. (Inherited from MarshalByRefObject.)
Public method Equals (Inherited from Object.)
Public method GetHashCode (Inherited from Object.)
Public method GetLifetimeService Security Critical. (Inherited from MarshalByRefObject.)
Public method GetMetadata Retrieves the specified metadata on the item.MSBuild is now included in Visual Studio instead of the .NET Framework. You can use MSBuild 12.0 side-by-side with versions previously deployed with the .NET Framework.For more information, see What's New in MSBuild 12.0.
Public method GetType (Inherited from Object.)
Public method InitializeLifetimeService Security Critical. When overridden in a derived class, gives task items infinite lease time.MSBuild is now included in Visual Studio instead of the .NET Framework. You can use MSBuild 12.0 side-by-side with versions previously deployed with the .NET Framework.For more information, see What's New in MSBuild 12.0. (Overrides MarshalByRefObject.InitializeLifetimeService.)
Public method RemoveMetadata Removes the specified metadata on the item.MSBuild is now included in Visual Studio instead of the .NET Framework. You can use MSBuild 12.0 side-by-side with versions previously deployed with the .NET Framework.For more information, see What's New in MSBuild 12.0.
Public method SetMetadata Sets or modifies the value of the specified metadata on the item.MSBuild is now included in Visual Studio instead of the .NET Framework. You can use MSBuild 12.0 side-by-side with versions previously deployed with the .NET Framework.For more information, see What's New in MSBuild 12.0.
Public method ToString Gets the item specification.MSBuild is now included in Visual Studio instead of the .NET Framework. You can use MSBuild 12.0 side-by-side with versions previously deployed with the .NET Framework.For more information, see What's New in MSBuild 12.0. (Overrides Object.ToString().)

Top

Operators

  Name Description
Public operatorStatic member Explicit(TaskItem to String) Allows an explicit type cast from a TaskItem to a String, and returns the ItemSpec for that item.MSBuild is now included in Visual Studio instead of the .NET Framework. You can use MSBuild 12.0 side-by-side with versions previously deployed with the .NET Framework.For more information, see What's New in MSBuild 12.0.

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method ITaskItem2.CloneCustomMetadataEscaped ITaskItem2 implementation which returns a clone of the metadata on this object. Values returned are in their original escaped form.MSBuild is now included in Visual Studio instead of the .NET Framework. You can use MSBuild 12.0 side-by-side with versions previously deployed with the .NET Framework.For more information, see What's New in MSBuild 12.0.
Explicit interface implemetationPrivate property ITaskItem2.EvaluatedIncludeEscaped ITaskItem2 implementation which gets or sets the item include value. For disk-based items this would be the file path.MSBuild is now included in Visual Studio instead of the .NET Framework. You can use MSBuild 12.0 side-by-side with versions previously deployed with the .NET Framework.For more information, see What's New in MSBuild 12.0.
Explicit interface implemetationPrivate method ITaskItem2.GetMetadataValueEscaped ITaskItem2 implementation which allows the values of metadata on the item to be queried.MSBuild is now included in Visual Studio instead of the .NET Framework. You can use MSBuild 12.0 side-by-side with versions previously deployed with the .NET Framework.For more information, see What's New in MSBuild 12.0.
Explicit interface implemetationPrivate method ITaskItem2.SetMetadataValueLiteral ITaskItem2 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.MSBuild is now included in Visual Studio instead of the .NET Framework. You can use MSBuild 12.0 side-by-side with versions previously deployed with the .NET Framework.For more information, see What's New in MSBuild 12.0.

Top

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.

Thread Safety

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

See Also

Reference

Microsoft.Build.Utilities Namespace