Freigeben über


Project.AddItem Method

Definition

Adds an item.

Overloads

AddItem(String, String)

Adds an item with no metadata to the project. Any metadata can be added subsequently. Does not modify the XML if a wildcard expression would already include the new item. Evaluates on a best-effort basis: -expands with all items. Items that are defined in the XML below the new item may be used, even though in a real evaluation they would not be. -only this item is evaluated. Other items that might depend on it is not affected. This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state until reevaluation.

AddItem(String, String, IEnumerable<KeyValuePair<String,String>>)

Adds an item with metadata to the project. Metadata may be null, indicating no metadata. Does not modify the XML if a wildcard expression would already include the new item. Evaluates on a best-effort basis: -expands with all items. Items that are defined in the XML below the new item may be used, even though in a real evaluation they would not be. -only this item is evaluated. Other items that might depend on it is not affected. This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state until reevaluation.

AddItem(String, String)

Source:
Project.cs

Adds an item with no metadata to the project. Any metadata can be added subsequently. Does not modify the XML if a wildcard expression would already include the new item. Evaluates on a best-effort basis: -expands with all items. Items that are defined in the XML below the new item may be used, even though in a real evaluation they would not be. -only this item is evaluated. Other items that might depend on it is not affected. This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state until reevaluation.

public:
 System::Collections::Generic::IList<Microsoft::Build::Evaluation::ProjectItem ^> ^ AddItem(System::String ^ itemType, System::String ^ unevaluatedInclude);
public System.Collections.Generic.IList<Microsoft.Build.Evaluation.ProjectItem> AddItem (string itemType, string unevaluatedInclude);
[System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
public System.Collections.Generic.IList<Microsoft.Build.Evaluation.ProjectItem> AddItem (string itemType, string unevaluatedInclude);
member this.AddItem : string * string -> System.Collections.Generic.IList<Microsoft.Build.Evaluation.ProjectItem>
[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]
member this.AddItem : string * string -> System.Collections.Generic.IList<Microsoft.Build.Evaluation.ProjectItem>
Public Function AddItem (itemType As String, unevaluatedInclude As String) As IList(Of ProjectItem)

Parameters

itemType
String

The item type of the added item.

unevaluatedInclude
String

Include attribute of the item to be added.

Returns

The added item.

Attributes

Remarks

Any metadata can be added later. Does not modify the project source if a wildcard expression already includes the new item.

Evaluation takes place on a best-effort basis. Items that are defined in the project source following the new item may be used for evaluation. Only this item is evaluated. Other items that might depend on it are not affected.

Applies to

AddItem(String, String, IEnumerable<KeyValuePair<String,String>>)

Source:
Project.cs

Adds an item with metadata to the project. Metadata may be null, indicating no metadata. Does not modify the XML if a wildcard expression would already include the new item. Evaluates on a best-effort basis: -expands with all items. Items that are defined in the XML below the new item may be used, even though in a real evaluation they would not be. -only this item is evaluated. Other items that might depend on it is not affected. This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state until reevaluation.

public:
 System::Collections::Generic::IList<Microsoft::Build::Evaluation::ProjectItem ^> ^ AddItem(System::String ^ itemType, System::String ^ unevaluatedInclude, System::Collections::Generic::IEnumerable<System::Collections::Generic::KeyValuePair<System::String ^, System::String ^>> ^ metadata);
public System.Collections.Generic.IList<Microsoft.Build.Evaluation.ProjectItem> AddItem (string itemType, string unevaluatedInclude, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string,string>> metadata);
member this.AddItem : string * string * seq<System.Collections.Generic.KeyValuePair<string, string>> -> System.Collections.Generic.IList<Microsoft.Build.Evaluation.ProjectItem>
Public Function AddItem (itemType As String, unevaluatedInclude As String, metadata As IEnumerable(Of KeyValuePair(Of String, String))) As IList(Of ProjectItem)

Parameters

itemType
String

The item type of the added item.

unevaluatedInclude
String

Include attribute of the item to be added.

metadata
IEnumerable<KeyValuePair<String,String>>

The metadata of the added item.

Returns

The added item.

Remarks

The metadata may be null, which indicates no metadata.

Evaluation takes place on a best-effort basis. Items that are defined in the project source following the new item may be used for evaluation. Only this item is evaluated. Other items that might depend on it are not affected.

Applies to