2017-08-30 26 views
1

では動作しません除外するこのItemgroup ItemsFromAnotherTargetは含まれていますMSBuildのItemGroupはワイルドカード

..\..\References\AnotherFolder\ReferencedAssembly.dll 
bin\GeneratedAssembly1.dll 
bin\GeneratedAssembly2.dll 
somefolder\somefile.txt 
somefolder\somefile.exe 
bin\anexe.exe 

アイデアは、次の

bin\GeneratedAssembly1.dll 
bin\GeneratedAssembly2.dll 
somefolder\somefile.exe 
bin\anexe.exe 

は、だから私は持っ含む他の項目グループBinaryFilesを生成することです

<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フォルダが複数のフォルダとDLLを持っているかもしれないです、我々は全体Referencesフォルダを除外する必要があります。どのようにワイルドカードを使用してフィルタリングを行うか考えていますか?

+1

あなたがここに答えを使用することができますhttps://stackoverflow.com/questions/35498608/msbuild-how-can-i-exclude-wildcard-paths-matching-a-regexとそれので正規表現を調整\ References \と一致するものはすべて除外されます。そうでなければ、を除外するすべてのファイルをリストアップし、そのリストに基づいてBinaryFilesグループをフィルタリングする必要があります。 – stijn

+0

どのバージョンのmsbuildを使用していますか? –

+0

Microsoft(R)ビルドエンジンバージョン15.1.1012.6693 – dushyantp

答えて

2

Referencesフォルダを除外することができる唯一の方法はRegexです。それはハッキーのように思われ、他の提案は大歓迎です。

<ItemGroup> 
    <BinaryFiles Include="@(ItemsFromAnotherTarget)" Condition="(!$([System.Text.RegularExpressions.Regex]::IsMatch('%(Identity)', `.\\References\\.`))) and ('%(Extension)'=='.dll' or '%(Extension)'=='.exe')" /> 
</ItemGroup> 
関連する問題