此Itemgroup ItemsFromAnotherTarget包含:
..\..\References\AnotherFolder\ReferencedAssembly.dll
bin\GeneratedAssembly1.dll
bin\GeneratedAssembly2.dll
somefolder\somefile.txt
somefolder\somefile.exe
bin\anexe.exe其思想是生成另一个包含以下内容的项目组BinaryFiles
bin\GeneratedAssembly1.dll
bin\GeneratedAssembly2.dll
somefolder\somefile.exe
bin\anexe.exe因此,我有以下几点:
<ItemGroup>
<BinaryFiles Include="@(ItemsFromAnotherTarget)" Condition="'%(Extension)'=='.dll' or '%(Extension)'=='.exe'" Exclude="..\..\References\AnotherFolder\ReferencedAssembly.dll" />
</ItemGroup>因此,这将生成所需的物料组。但是如果我们用通配符替换Exclude,它就不能工作了。
Exclude="..\..\**\References\**"
Exclude="..\..\References\**\*.dll"
Exclude="..\..\References\**\*"
None of these work.问题是References文件夹可能有多个文件夹和References,我们需要排除整个dlls文件夹。你知道如何使用通配符进行过滤吗?
发布于 2017-08-31 16:23:49
我唯一可以得到排除References文件夹的方法是通过正则表达式。这似乎有点老生常谈,任何其他建议都是受欢迎的。
<ItemGroup>
<BinaryFiles Include="@(ItemsFromAnotherTarget)" Condition="(!$([System.Text.RegularExpressions.Regex]::IsMatch('%(Identity)', `.\\References\\.`))) and ('%(Extension)'=='.dll' or '%(Extension)'=='.exe')" />
</ItemGroup>https://stackoverflow.com/questions/45964967
复制相似问题