12

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?

sharptooth
  • 167,383
  • 100
  • 513
  • 979

1 Answers1

19

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>
rocky
  • 7,506
  • 3
  • 33
  • 48
vharavy
  • 4,881
  • 23
  • 30
  • I get `error : Error initializing task Move: Not registered task Move` – knocte May 25 '17 at 04:45
  • "You cannot use regular expression directly in task parameters" - Any perticular reason why it is not possible. – Sisir Jun 06 '19 at 06:52