Compartilhar via


Project.SetProperty(String, String) Method

Definition

Set or add a property with the specified name and value. Overwrites the value of any property with the same name already in the collection if it did not originate in an imported file. If there is no such existing property, uses this heuristic: Updates the last existing property with the specified name that has no condition on itself or its property group, if any, and is in this project file rather than an imported file. Otherwise, adds a new property in the first property group without a condition, creating a property group if necessary after the last existing property group, else at the start of the project. Returns the property set. Evaluates on a best-effort basis: -expands with all properties. Properties that are defined in the XML below the new property may be used, even though in a real evaluation they would not be. -only this property is evaluated. Anything else that would depend on its value 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:
 Microsoft::Build::Evaluation::ProjectProperty ^ SetProperty(System::String ^ name, System::String ^ unevaluatedValue);
public Microsoft.Build.Evaluation.ProjectProperty SetProperty (string name, string unevaluatedValue);
member this.SetProperty : string * string -> Microsoft.Build.Evaluation.ProjectProperty
Public Function SetProperty (name As String, unevaluatedValue As String) As ProjectProperty

Parameters

name
String

The name of the property to set.

unevaluatedValue
String

The new unevaluated value of the property.

Returns

The property.

Remarks

If there is no property with the given name, updates the last existing property with the given name that has no condition on itself or its property group, unless it originated in an imported file.

Otherwise, adds a new property in the first property group without a condition, creating a property group if necessary after the last existing property group, else at the start of the project.

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

Applies to