Share via


ProjectElement.Condition Property

Gets or sets the Condition value.

It will return empty string IFF a condition attribute is legal but it’s not present or has no value.

It will return null IFF a Condition attribute is illegal on that element.

Removes the attribute if the value to set is empty.

It is possible for derived classes to throw an InvalidOperationException if setting the condition is not applicable for those elements.

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.

Namespace:  Microsoft.Build.Construction
Assembly:  Microsoft.Build (in Microsoft.Build.dll)

Syntax

'Declaration
Public Overridable Property Condition As String
public virtual string Condition { get; set; }
public:
virtual property String^ Condition {
    String^ get ();
    void set (String^ value);
}
abstract Condition : string with get, set 
override Condition : string with get, set
function get Condition () : String 
function set Condition (value : String)

Property Value

Type: System.String
Returns the Condition attribute value. Returns an empty string if the attribute is not present.

Remarks

Removes the Condition attribute if the value to set is set to null or an empty string. If the Condition attribute is not present, returns an empty string instead of throwing an exception because a nonexistent condition is implicitly true

For the "ProjectExtensions" element, the getter returns null and the setter throws an exception for any value.

.NET Framework Security

See Also

Reference

ProjectElement Class

Microsoft.Build.Construction Namespace