Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I move a bunch of files using a Move MSBuild task and a wildcard?

Tags:

msbuild

I have a folder with files that have names starting with App_Web_ and ending with .dll. I don't know what's in between those parts and I don't know the number of files. I need MSBuild to move those files into another folder.

So I composed this:

<Move
    SourceFiles="c:\source\App_Web_*.dll"
    DestinationFolder="c:\target"
/>

but when the target runs I get the following output:

error MSB3680: The source file "c:\source\App_Web_*.dll" does not exist.

The files are definitely there.

What am I doing wrong? How do I have the files moved?

like image 696
sharptooth Avatar asked Oct 05 '12 11:10

sharptooth


1 Answers

You cannot use regular expression directly in task parameters. You need to create an item containing list of files to move and pass its content to the task:

<ItemGroup>
    <FilesToMove Include="c:\source\App_Web_*.dll"/>
</ItemGroup>

MSBuild will expand regular expression before passing it to the task executor. So later in some target you may invoke Move task:

<Target Name="Build">
    <Move
        SourceFiles="@(FilesToMove)"
        DestinationFolder="C:\target"
    />
</Target>
like image 173
vharavy Avatar answered Oct 15 '22 12:10

vharavy