Partilhar via


Project.RemoveItem Method

Removes an item from the project. The item to be removed must be present in the project, and must not originate from an imported file.

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.Evaluation
Assembly:  Microsoft.Build (in Microsoft.Build.dll)

Syntax

'Declaration
Public Function RemoveItem ( _
    item As ProjectItem _
) As Boolean
public bool RemoveItem(
    ProjectItem item
)
public:
bool RemoveItem(
    ProjectItem^ item
)
member RemoveItem : 
        item:ProjectItem -> bool
public function RemoveItem(
    item : ProjectItem
) : boolean

Parameters

Return Value

Type: System.Boolean
Returns true if the item is present in this evaluated project; otherwise false. Normally this method returns true, since if the requested item is not present, the method throws an exception. If the item is present only in the ItemsIgnoringCondition collection, however, the method returns false.

Remarks

If the item group containing the item becomes empty, it is also removed.

If the item originates from a wildcard or semicolon-separated expression, the expression is first expanded into multiple items.

The project is updated, but no further evaluation occurs until reevaluation. For example, if an item of type "i" is removed, "j" which is evaluated from "@(i)" is not modified until reevaluation.

.NET Framework Security

See Also

Reference

Project Class

Microsoft.Build.Evaluation Namespace