How does visual studio determine what to copy to the output directory with multi-project solutions?

Josh Kodroff picture Josh Kodroff · Dec 9, 2008 · Viewed 14.3k times · Source

Let's say we have a solution with the following structure:

  • Project.DAL - Data access layer, depends on a lower-level library, e.g. Oracle.DataAccess w/copy local = true
  • Project.BLL - Business logic layer, references Project.DAL as project
  • Project.UI - UI layer, compiles to executable, references Project.BLL, default project

When Project.UI is compiled, VS is smart enough to copy Project.DAL.dll to the output directory, but it's not smart enough to figure out that I wanted Oracle.DataAccess to be copied to the output directory as well for distribution to clients.

Can anyone explain why this is so? Is it because it sees Oracle.DataAccess in the GAC and assumes that clients will have it in the GAC as well?

It's not that big of a deal, but it's kinda annoying that every time I add a new assembly reference, I have to remember to set it to copy local and add an item to copy it in my build script as well.

Answer

Jonathan picture Jonathan · Feb 14, 2010

One more thing.

When you don't use the referenced DLL in your code at all, it will ignore the CopyLocal and won't copy it to your output directory.