Just wondering if someone could help me with some msbuild scripts that I am trying to write. What I would like to do is copy all the files and sub folders from a folder to another folder using msbuild.
{ProjectName}
|----->Source
|----->Tools
|----->Viewer
|-----{about 5 sub dirs}
What I need to be able to do is copy all the files and sub folders from the tools folder into the debug folder for the application. This is the code that I have so far.
<ItemGroup>
<Viewer Include="..\$(ApplicationDirectory)\Tools\viewer\**\*.*" />
</ItemGroup>
<Target Name="BeforeBuild">
<Copy SourceFiles="@(Viewer)" DestinationFolder="@(Viewer->'$(OutputPath)\\Tools')" />
</Target>
The build script runs but doesn't copy any of the files or folders.
Thanks
This is copy task i used in my own project, it was working perfectly for me that copies folder with sub folders to destination successfully:
In my case i copied a project's publish folder to another destination folder, i think it is similiar with your case.
Personally I have made use of CopyFolder which is part of the SDC Tasks Library.
http://sdctasks.codeplex.com/
This is the example that worked:
source: https://msdn.microsoft.com/en-us/library/3e54c37h.aspx
I was searching help on this too. It took me a while, but here is what I did that worked really well.
This recursively copied the contents of the folder named
antlrcs
to the$(TargetDir)
.I think the problem might be in how you're creating your ItemGroup and calling the Copy task. See if this makes sense:
\**\*.*
help to get files from all the folder. RecursiveDir help to put all the file in the respective folder...