我有以下 MSBuild .proj 文件内容:
<ItemGroup>
<Exclude Include="*2.*"></Exclude>
</ItemGroup>
<ItemGroup>
<!-- I have 3 files in the current directory: File1.cpp, File2.cpp and File3.cpp -->
<ModuleInclude Include="*.cpp" Exclude="@(Exclude)"></ModuleInclude>
<!-- I have 3 files in the Subfolder directory: eFile1.h, eFile2.h and eFile3.h -->
<ModuleInclude Include="Subfolder\*.h" Exclude="@(Exclude->'Subfolder\%(identity)')"></ModuleInclude>
</ItemGroup>
<Target Name="Default">
<Message Text="ModuleIncludes: %(ModuleInclude.identity)" />
<Message Text="Excluded Items: @(Exclude)" />
<Message Text="Excluded Subfolder Items: @(Exclude->'Subfolder\%(identity)')" />
</Target>
我看到以下输出:
ModuleIncludes: File1.cpp
ModuleIncludes: File3.cpp
ModuleIncludes: Subfolder\eFile1.h
ModuleIncludes: Subfolder\eFile2.h
ModuleIncludes: Subfolder\eFile3.h
Excluded Items: File2.cpp
Excluded Subfolder Items: Subfolder\File2.cpp
我真正需要的是包含以下子文件夹文件
ModuleIncludes: Subfolder\eFile1.h
ModuleIncludes: Subfolder\eFile3.h
因此,排除的子文件夹项目应为:
Excluded Subfolder Items: Subfolder\eFile2.h
为了能够得到这样的输出,我需要表达式
Subfolder\*2.*
我正在使用的语法
@(Exclude->'Subfolder\%(identity)')
没有给我我需要的东西。正确的语法是什么?或者这是不可能的?