Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify folder structure with msbuild copy task

Tags:

I have the following msbuild script that copies the entire DeploymentDirectory to the VersionSpecificDirectory. Here is the snippet:

<CreateItem Include="$(DeploymentDirectory)/**/*.*" >   <Output ItemName="AllDeploymentFilesToCopy" TaskParameter="Include" /> </CreateItem> <Copy SourceFiles="@(AllDeploymentFilesToCopy)"       DestinationFiles="@(AllDeploymentFilesToCopy->'$(VersionSpecificDirectory)\%(RecursiveDir)%(Filename)%(Extension)')" /> 

What would the script be for copying all the files in the DeploymentDirectory instead of the directory itself?

Update: I tried changing the direction of the slash to be a backward slash and the problem still exists.

Another Update: This was unrelated to the msbuild code. Both the code in my question and the code in the answer works fine for doing this.

like image 490
Michael Hedgpeth Avatar asked Apr 22 '09 21:04

Michael Hedgpeth


People also ask

How do I copy only the folder structure?

Type "xcopy", "source", "destination" /t /e in the Command Prompt window. Instead of “ source ,” type the path of the folder hierarchy you want to copy. Instead of “ destination ,” enter the path where you want to store the copied folder structure. Press “Enter” on your keyboard.

What is the command to copy directory structure?

Use the cp command to create a copy of the contents of the file or directory specified by the SourceFile or SourceDirectory parameters into the file or directory specified by the TargetFile or TargetDirectory parameters.


1 Answers

Try this:

<ItemGroup>     <MySourceFiles Include="c:\MySourceTree\**\*.*"/> </ItemGroup>  <Target Name="CopyFiles">     <Copy         SourceFiles="@(MySourceFiles)"         DestinationFiles="@(MySourceFiles->'c:\MyDestinationTree\%(RecursiveDir)%(Filename)%(Extension)')"     /> </Target> 

From MSDN.

like image 133
Matt Hanson Avatar answered Sep 19 '22 13:09

Matt Hanson