[ACCEPTED]-How to save DLLs in a different folder when compiling in Visual Studio?-projects-and-solutions

Accepted answer
Score: 18

There are 2 parts of your question:

How to 45 configure solutions to build assemblies/EXE 44 into folders of your choice - this is configured 43 through properties of the project in VS 42 (project properties -> build -> output 41 path). Also value of check "copy local" property 40 on each reference.

How to load assemblies 39 files from non-default locations (i.e. from 38 your ...\Libraries folder) - you need to 37 make changes to your app.config file to 36 add this non-default paths to assembly search 35 location..

Link to Microsoft site no longer 34 works, so summary from wayback machine: How to load an assembly at runtime that is located in a folder that is not the bin folder of the application:

Method 33 1: Install the assembly in the global assembly 32 cache (GAC). The GAC is a computer-wide 31 code cache where the common language runtime 30 is installed. The GAC stores assemblies 29 that you specifically designate to be shared 28 by several applications.

Note You can only 27 install strong-named assemblies in the GAC.

Method 26 2: Use an application configuration (.config) file 25 with the tags A .config file contains 24 the following settings:

• Settings that 23 are specific to an application

• Settings 22 that the common language runtime reads, such 21 as the assembly binding policy settings 20 and the remoting objects settings

• Settings 19 that the application reads

The <codeBase> tags specify 18 where the common language runtime can find 17 an assembly. The common language runtime 16 applies the settings of the <codeBase> tags from the 15 .config file. The settings of the <codeBase> tags 14 determine the version and the location of 13 the assembly.

Method 3: Use the AssemblyResolve 12 event The AssemblyResolve event fires 11 whenever the common language runtime tries 10 to bind to an assembly and fails. You can 9 use the AddHandler method to add an event 8 handler to the application that returns 7 the correct assembly whenever the AssemblyResolve 6 event fires.

The AssemblyResolve event handler 5 must return an [Assembly] object, and the 4 common language runtime must bind to this 3 object. Typically, you can use the Assembly.LoadFrom 2 method to load the assembly and then to 1 return the object.

Score: 9

Correct answers were given earlier. I'll 5 just mention that there is a nuget package 4 for this called PrettyBin.

Install it on your startup 3 project. DLLs and XMLs will go to a lib 2 folder and you'll have a working example 1 of how it's done, if you won't to customize.

Score: 1

Set Reference path in project peoperties.

You 3 can also specify where your compiled exe 2 goes by specifying Output path in project 1 peoperties.

Score: 1

You'll find best practices for organizing 3 project references here: http://codebetter.com/patricksmacchia/2009/01/11/lessons-learned-from-the-nunit-code-base/

Look under chapter 2 "The VisualStudio Project Reference 1 + Copy Local true option is evil!"

Score: 0

Yes it is possible, you'd do it in your 3 msbuild script. While I can't give you 2 an exact answer, look here at this question 1 on SO Copy all files and folders using msbuild

More Related questions