Project.GetAllGlobs Method

Definition

Overloads

GetAllGlobs(String, EvaluationContext)

Source:
Project.cs
C#
public System.Collections.Generic.List<Microsoft.Build.Evaluation.GlobResult> GetAllGlobs(string itemType, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext);

Parameters

itemType
String

Type of the item.

evaluationContext
EvaluationContext

The evaluation context to use in case reevaluation is required. To avoid reevaluation use RecordEvaluatedItemElements.

Returns

Applies to

MSBuild 17 和其他版本
產品 版本
MSBuild 15, 16, 17
MSBuild (.NET Core) 15, 16, 17

GetAllGlobs(String)

Source:
Project.cs

Overload of GetAllGlobs().

C#
public System.Collections.Generic.List<Microsoft.Build.Evaluation.GlobResult> GetAllGlobs(string itemType);

Parameters

itemType
String

Confine search to item elements of this type.

Returns

Applies to

MSBuild 17 和其他版本
產品 版本
MSBuild 15, 16, 17
MSBuild (.NET Core) 15, 16, 17

GetAllGlobs(EvaluationContext)

Source:
Project.cs
C#
public System.Collections.Generic.List<Microsoft.Build.Evaluation.GlobResult> GetAllGlobs(Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext);

Parameters

evaluationContext
EvaluationContext

The evaluation context to use in case reevaluation is required. To avoid reevaluation use RecordEvaluatedItemElements.

Returns

Applies to

MSBuild 17 和其他版本
產品 版本
MSBuild 15, 16, 17
MSBuild (.NET Core) 15, 16, 17

GetAllGlobs()

Source:
Project.cs

Finds all the globs specified in item includes.

C#
public System.Collections.Generic.List<Microsoft.Build.Evaluation.GlobResult> GetAllGlobs();

Returns

List of GlobResult.

Examples

<P>*.txt</P>

<Bar Include="bar"/> (both outside and inside project cone)
<Zar Include="C:\**\*.foo"/> (both outside and inside project cone)
<Foo Include="*.a;*.b" Exclude="3.a"/>
<Foo Remove="2.a" />
<Foo Include="**\*.b" Exclude="1.b;**\obj\*.b;**\bar\*.b"/>
<Foo Include="$(P)"/>
<Foo Include="*.a;@(Bar);3.a"/> (If Bar has globs, they will have been included when querying Bar ProjectItems for globs)
<Foo Include="*.cs" Exclude="@(Bar)"/>

Example result:

[
GlobResult(glob: "C:\**\*.foo", exclude: []),
GlobResult(glob: ["*.a", "*.b"], exclude=["3.a"], remove=["2.a"]),
GlobResult(glob: "**\*.b", exclude=["1.b, **\obj\*.b", **\bar\*.b"]),
GlobResult(glob: "*.txt", exclude=[]),
GlobResult(glob: "*.a", exclude=[]),
GlobResult(glob: "*.cs", exclude=["bar"])
].

Remarks

MsBuildGlob is a IMSBuildGlob that combines all globs in the include element and ignores all the fragments in the exclude attribute and all the fragments in all Remove elements that apply to the include element.

Users can construct a composite glob that incorporates all the globs in the Project:

var uberGlob = new CompositeGlob(project.GetAllGlobs().Select(r => r.MSBuildGlob).ToArray());
uberGlob.IsMatch("foo.cs");

Applies to

MSBuild 17 和其他版本
產品 版本
MSBuild 15, 16, 17
MSBuild (.NET Core) 15, 16, 17