17

I have a MVC project and I want to split its output.

I want to copy all DLL files of this project (all content from the directory Bin) to one directory, and all Views (content of the directory View) to another output directory.

Settings of the project in VS 2010 does not allow me to do that simply.

I may specify only one Output path in settings and I can't specify which directories or file types to copy and where.

I think that I should leave the output directory to its default and then I need to split the output like the way I want using Post-build command.

Maybe someone did something similar and have any ideas how to do it best?

MxNx
  • 1,342
  • 17
  • 28
angularrocks.com
  • 26,767
  • 13
  • 87
  • 104
  • After the files have been created in the output folder, can the different types of filed easily be distinguished by their ending? – Doc Brown Dec 01 '10 at 12:34

3 Answers3

23

The solution is

1) Set Output Path to directory where you want to copy your *dll files in project properties

2) Using post-build event to copy the content of the directory View to whatever directory you want

in my case

1) Output path i set to

..\MyDestinationProjectName\Bin\

2) Post-build event to copy View directory looks like this

xcopy "$(ProjectDir)\Views" "$(SolutionDir)\MyDestinationProjectName\Plugins\Views\$(ProjectName)\" /s /i /y

angularrocks.com
  • 26,767
  • 13
  • 87
  • 104
  • 1
    '/I' parameter solved my error problem that occurs when a file already exist in the destination – Mert Akcakaya Apr 09 '13 at 13:05
  • 2
    From a default project, I wanted to copy the compiled executable to a destination folder. My Post-Build Event cmd was `xcopy "$(SolutionDir)$(Configuration)\$(TargetName)$(TargetExt)" "C:\MyOutputFolder" /s /i /y`, just in case it helps anyone out there. Very useful! – caiosm1005 Dec 29 '13 at 14:25
  • /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. – Muhammad Rehan Qadri Feb 28 '17 at 06:59
3

This should be a comment to @caiosm1005, but I lack points. As indicated by @Riapp use the xcopy command. A detailed explanation of the switches can be found here Xcopy and Xcopy32 Switches

My solution was: xcopy "$(TargetDir)$(TargetFileName)" "C:\Mydestination" /s /i /y

The TargetDir contained the full path to the compiled file and the TargetFileName is the combination of TargetName and TargetExt. Do not add a backslash separator after a directory variable e.g. $(TargetDir)\$(TargetFileName) will fail because it will be interpreted as "TargetName**\\** TargetExt".

Once you look at the values in the Macros it should be easy to choose what you want. Remember you need to do this on each project within your solution. The build events can be found by right clicking on the project, selecting properties and then choosing the Build Events tab.

angularrocks.com
  • 26,767
  • 13
  • 87
  • 104
Bill Kidd
  • 1,130
  • 11
  • 13
  • Thank you. I've figured better ways of doing this some time after I made that comment. That's the way to go! – caiosm1005 Feb 15 '14 at 00:02
0

This should be a comment to caiosm1005, but I lack points. As indicated by Riap use the xcopy command. A detailed explanation of the switches can be found here Xcopy and Xcopy32 Switches

Bill Kidd
  • 1,130
  • 11
  • 13