Compartir a través de


ProjectItem.SetMetadataValue Method

Definition

Overloads

SetMetadataValue(String, String)

Adds metadata with the specified name and value to the item. Updates an existing metadata if one already exists with the same name on the item directly, as opposed to inherited from an item definition. Updates the evaluated project, but does not affect anything else in the project until reevaluation. For example, if a piece of metadata named "m" is added on item of type "i", it does not affect "j" which is evaluated from "@(j->'%(m)')" until reevaluation. Also if the unevaluated value of "m" is set to something that is modified by evaluation, such as "$(p)", the evaluated value will be set to literally "$(p)" until reevaluation. This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state without a reevaluation. Returns the new or existing metadatum.

SetMetadataValue(String, String, Boolean)

Overload of SetMetadataValue(String, String). Adds the option of not splitting the item element and thus affecting all sibling items. Sibling items are defined as all ProjectItem instances that were created from the same item element.

This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state without a reevaluation

SetMetadataValue(String, String)

Source:
ProjectItem.cs

Adds metadata with the specified name and value to the item. Updates an existing metadata if one already exists with the same name on the item directly, as opposed to inherited from an item definition. Updates the evaluated project, but does not affect anything else in the project until reevaluation. For example, if a piece of metadata named "m" is added on item of type "i", it does not affect "j" which is evaluated from "@(j->'%(m)')" until reevaluation. Also if the unevaluated value of "m" is set to something that is modified by evaluation, such as "$(p)", the evaluated value will be set to literally "$(p)" until reevaluation. This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state without a reevaluation. Returns the new or existing metadatum.

public:
 Microsoft::Build::Evaluation::ProjectMetadata ^ SetMetadataValue(System::String ^ name, System::String ^ unevaluatedValue);
public Microsoft.Build.Evaluation.ProjectMetadata SetMetadataValue (string name, string unevaluatedValue);
member this.SetMetadataValue : string * string -> Microsoft.Build.Evaluation.ProjectMetadata
Public Function SetMetadataValue (name As String, unevaluatedValue As String) As ProjectMetadata

Parameters

name
String

The name of the metadata to add.

unevaluatedValue
String

The unevaluated value of the metadata to add.

Returns

The new metadata. If metadata with the given name already exists, returns this metadata.

Remarks

Unevaluated value is assumed to be escaped as necessary

Applies to

SetMetadataValue(String, String, Boolean)

Source:
ProjectItem.cs

Overload of SetMetadataValue(String, String). Adds the option of not splitting the item element and thus affecting all sibling items. Sibling items are defined as all ProjectItem instances that were created from the same item element.

This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state without a reevaluation

public:
 Microsoft::Build::Evaluation::ProjectMetadata ^ SetMetadataValue(System::String ^ name, System::String ^ unevaluatedValue, bool propagateMetadataToSiblingItems);
public Microsoft.Build.Evaluation.ProjectMetadata SetMetadataValue (string name, string unevaluatedValue, bool propagateMetadataToSiblingItems);
member this.SetMetadataValue : string * string * bool -> Microsoft.Build.Evaluation.ProjectMetadata
Public Function SetMetadataValue (name As String, unevaluatedValue As String, propagateMetadataToSiblingItems As Boolean) As ProjectMetadata

Parameters

name
String

Metadata name

unevaluatedValue
String

Metadata value

propagateMetadataToSiblingItems
Boolean

If true, adds direct metadata to the ProjectItemElement from which this ProjectItem originated. The intent is to affect all other sibling items.

Returns

Returns the new or existing metadatum.

Applies to