Christian Finel/MSBuild: Copier un dossier avec wildcards

Created Thu, 02 Feb 2017 19:30:09 +0100
93 Words

This is a little trick to copy files from a regular expression with MSBuild.

With this example it becomes possible to use wildcards to identity to elements to copy.

<Target Name="BeforeBuild">
[...]
<ItemGroup>
  <\_FoldersToCopy Include="$(ProjectDir)MyFolder\*TargetFolderSuffix\*.ext" />
</ItemGroup>
<Copy SourceFiles="@(_FoldersToCopy)"
  DestinationFolder="@(_FoldersToCopy->'$(TargetDir)MyFolder\%(RecursiveDir)')" />
[...]
</Target>

This is very useful when you application uses a plugin pattern and you wish to copy all the libraries to the output directory.

Remarques