Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 295
Josh Kodroff Avatar asked Dec 09 '08 17:12

Josh Kodroff


People also ask

What is the use of copy to output directory Visual Studio?

"Copy to Output Directory" is the property of the files within a Visual Studio project, which defines if the file will be copied to the project's built path as it is. Coping the file as it is allows us to use relative path to files within the project.

How do I change the output path in Visual Studio?

Right-click on the project node in Solution Explorer and select Properties. Expand the Build section, and select the Output subsection. Find the Base output path for C#, and type in the path to generate output to (absolute or relative to the root project directory), or choose Browse to browse to that folder instead.

Which of the following target creates an output folder for storing the files generated during the?

The root of the uncompressed files tree is formed by a subfolder called Target System in the package's output folder; this corresponds to the Target System root node on the Files and folders project page. The other folders are created under the Target System subfolder.


1 Answers

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.

like image 106
Jonathan Avatar answered Oct 24 '22 20:10

Jonathan