C# – Pre Build Event: Copy Folder and it’s SubFolders and files into Build Directory using XCopy

cvisual studio 2010winforms

I have Window Application and I have some plugins & it's ChildPlugins which I placed in My Application folder structure(see folder structure image). I used SVN as source control so, every folder has .SVN folder.

Here is My Question:

Below image is my directory structure for Plugins. All folder have some files related it plugins. Now I want to copy all folder (with SubFolders) & it's files to my Application Build output path by using Pre Built Event.

**Plugins Directory structure**

After searching on net I found that by using XCopy I can achieve what I want. By using below code I can copy Plugins directory & it's files but can't able to copy it's sub folders & Sub folder Files .

xcopy "$(SolutionDir)Plugins\*.*" "$(SolutionDir)Windows\Host\Host.GUI\bin\x86\$(ConfigurationName)\Plugins\" /Y/D

I want to copy Folder & it's all subfolders with all files and want to exclude .SVN. Can anyone point me How can I do this?

Thanks.

Best Answer

I have used this:

xcopy "$(ProjectDir)MyFolder\*.*" "$(SolutionDir)ConsoleApplication1\bin\Release\MyFolder" /Y /I /E

And worked fine, the folder 'MyFolder' appear into my 'Release' folder when I compile the project with all the documents in it.

Something to point out here is that the path that is after $(SolutionDir) would change depending of the name of your solution, my solution is ConsoleApplication1.