.NET Framework Bookmark and Share   
 index > MSBuild > Batching a file copy operation issue
 

Batching a file copy operation issue

Hello,

I am running into an issue when trying to batch a copy operation. If I remove the %(RecursiveDir) from the code below, the script works, although all the files are copied under the main destination folder. I would expect that using %(RecursiveDir) to solve this problem, although, it doesn't work. How should the script be modified to recursively copy files to multiple destinations?

Thank you,
Alin

<?

xml version="1.0" encoding="utf-8"?>

<

Project DefaultTargets="Main" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >

<

Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>

<

UsingTask AssemblyFile="$(MSBuildExtensionsPath)\MSBuild.Community.Tasks\MSBuild.Community.Tasks.dll" TaskName="MSBuild.Community.Tasks.Time" />

<

PropertyGroup>

</

PropertyGroup>

<

ItemGroup>

<

IISSourceFiles Include="..\_PublishedWebsites\**\*.*"/>

</

ItemGroup>

<

ItemGroup>

<

SetE Include="01">

<

IISServerShare>C:\Temp\1</IISServerShare>

<

Do>true</Do>

</

SetE>

<

SetE Include="02">

<

IISServerShare>C:\temp\2</IISServerShare>

<

Do>true</Do>

</

SetE>

</

ItemGroup>

<

Target Name="Main">

<

Copy

SourceFiles="@(IISSourceFiles)"

DestinationFolder="%(SetE.IISServerShare)%(RecursiveDir)" />

</

Target>

</

Project>

Alin Dumitrescu
Unfortunately batching on another ItemGroupusing RecursiveDir doesn't work. You need to introduce a new ItemGroup and use it to do the multiple copy, e.g.

<Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<IISSourceFiles Include="c:\demo1\**\*.*"/>
<SetE Include="01">
<IISServerShare>C:\Temp\1</IISServerShare>
<Do>true</Do>
</SetE>
<SetE Include="02">
<IISServerShare>C:\temp\2</IISServerShare>
<Do>true</Do>
</SetE>
</ItemGroup>
<Target Name="Main">
<ItemGroup>
<FileToCopy Include="@(IISSourceFiles)">
<Destination>%(SetE.IISServerShare)</Destination>
</FileToCopy>
</ItemGroup>
<Copy SourceFiles="@(FileToCopy)" DestinationFolder="%(Destination)\%(RecursiveDir)" />

</Target>
</Project>
Mike Fourie
Unfortunately batching on another ItemGroupusing RecursiveDir doesn't work. You need to introduce a new ItemGroup and use it to do the multiple copy, e.g.

<Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<IISSourceFiles Include="c:\demo1\**\*.*"/>
<SetE Include="01">
<IISServerShare>C:\Temp\1</IISServerShare>
<Do>true</Do>
</SetE>
<SetE Include="02">
<IISServerShare>C:\temp\2</IISServerShare>
<Do>true</Do>
</SetE>
</ItemGroup>
<Target Name="Main">
<ItemGroup>
<FileToCopy Include="@(IISSourceFiles)">
<Destination>%(SetE.IISServerShare)</Destination>
</FileToCopy>
</ItemGroup>
<Copy SourceFiles="@(FileToCopy)" DestinationFolder="%(Destination)\%(RecursiveDir)" />

</Target>
</Project>
Mike Fourie

You can use google to search for other answers

Custom Search

More Threads

• Error with Computed field using VS2005
• Is it possible to bootstrap tasks?
• What MSBuild property shows if the build project was executed from a command prompt vs the VS IDE?
• How to have VS 2005 IDE auto version increment assemblies?
• Need help setting file version value for non assembly .dll files
• Msbuild for vdproj
• Deployment and updateing
• trouble referencing System.Management.Automation
• Copying all the solution's output files to a folder
• debug info missing