Assume that we have a library Foo. Foo has some resources that are copied to the bin when it is built.
Assume that we have a solution Bar. We reference Foo in Bar, and want the resource files that Foo has in Bar's bin directory. Is this possible? Specifically, can this be done with executables?
Best How To :
You have a couple of options at least.
One is to make Foo a dependency of Bar. In other words, add the Foo project to Bar's dependencies, then set the reference properties for Foo to "Copy Local: True".
Another way to have a little more control over what happens post-build is to write your own post-build script and have it execute on successful build.
For example, whenever I do a build of project Foo I might want to copy the output to a deployment directory. To do this, I could add the following to the build events (project properties --> Build Events --> Post-build event command line)
$(ProjectDir)PostBuild.bat $(ProjectName) $(Platform) $(Configuration)
This runs my batch file, PostBuild.bat, and includes some variables that the batch file is expecting. The batch file looks like this:
REM A list of all Macros --> https://msdn.microsoft.com/en-us/library/c02as0cs.aspx
REM Kill the built app if we forgot to...
REM Make the target dir if it doesn't exist
IF NOT EXIST C:\DeploymentDirectory\%1 mkdir C:\DeploymentDirectory\%1
ROBOCOPY E:\repos\MyFooProject\%1\%1\bin\%2\%3\ C:\DeploymentDirectory\%1\ *.dll *.xml *.exe *.pdb *.config /purge
REM Robocopy always exits with a code, which will cause
REM VS to think something bad happened :-(
REM So the following is to handle that
if %ERRORLEVEL% GEQ 8 goto failed
rem End of batch file
rem Do not pause as it will pause msbuild.