Copy a single file in MSBuild without using Exec or ItemGroup

execitemgroupmsbuild

Is there any way to do this? I just need to copy a single file and thought there may be some syntax for the SourceFiles parameter of the Copy task that means you don't need to define an ItemGroup beforehand, I'd rather stick with ItemGroup than use Exec though.

Best Answer

Copy files also takes a straight propertygroup as input:

<PropertyGroup>
  <SourceFile>Some file</SourceFile>
</PropertyGroup>
<Copy SourceFiles="$(SourceFile)" DestinationFolder="c:\"/> 

Or even just a string

<Copy SourceFiles="Pathtofile" DestinationFolder="c:\"/>