Copy file(s) from one project to another using post build event…VS2010

xcopy "$(ProjectDir)Views\Home\Index.cshtml" "$(SolutionDir)MEFMVCPOC\Views\Home"

and if you want to copy entire folders:

xcopy /E /Y "$(ProjectDir)Views" "$(SolutionDir)MEFMVCPOC\Views"

Update: here’s the working version

xcopy "$(ProjectDir)Views\ModuleAHome\Index.cshtml" "$(SolutionDir)MEFMVCPOC\Views\ModuleAHome\" /Y /I

Here are some commonly used switches with xcopy:

  • /I – treat as a directory if copying multiple files.
  • /Q – Do not display the files being copied.
  • /S – Copy subdirectories unless empty.
  • /E – Copy empty subdirectories.
  • /Y – Do not prompt for overwrite of existing files.
  • /R – Overwrite read-only files.

Leave a Comment