1

Recently I have noticed when compiling that Visual Studio is filling up my /bin/Debug folder with about 20 .dll files, which I previously linked from a /assets/packages folder where I thought I would keep them to ensure /bin/Debug cleaner, so when I noticed they were all in /bin/Debug I decided to move them all back to /assets/packages and then when I recompiled my application to ensure they were all re-added correctly with the new location, it put them all back in the /bin/debug folder? they remained in the /assets/packages folder but they all were copied in to the /bin/debug folder.

How can I get it to stay in the folder I linked them in via references?

Liam Savage
  • 167
  • 12

2 Answers2

2

You should set Copy Local on the Reference to false.

To quote MSDN: "The Copy Local property (corresponding to CopyLocal) determines whether a reference is copied to the local bin path. At run time, a reference must be located in either the Global Assembly Cache (GAC) or the output path of the project. If this property is set to true, the reference is copied to the output path of the project at run time."

https://msdn.microsoft.com/en-us/library/t1zz5y8c(v=vs.100).aspx

ProgrammingLlama
  • 36,677
  • 7
  • 67
  • 86
  • I just tried this, my whole application crashed and said it couldn't find the .dll – Liam Savage Feb 28 '17 at 06:06
  • @LiamSavage As the MSDN quote says, they DLLs need to be located in the GAC, or the output path of the project, for the project to execute at runtime. – ProgrammingLlama Feb 28 '17 at 06:11
  • 1
    @LiamSavage Consider it this way: You start your application, it needs a library. First, it looks in the local folder to see if the library is there. If it doesn't, it then looks in the GAC. If it can't find it in the GAC, it concludes that the dll doesn't exist. Which is exactly what you'd expect it to do. – ProgrammingLlama Feb 28 '17 at 06:20
  • Then how can I just make them load in a specific folder? surely there has to be a way.. – Liam Savage Feb 28 '17 at 06:20
  • 2
    @LiamSavage sure there is, just subscribe to the [`AppDomain.AssemblyResolve`](https://msdn.microsoft.com/en-us/library/system.appdomain.assemblyresolve(v=vs.110).aspx) event and have your code check the folder it needs to check. – Scott Chamberlain Feb 28 '17 at 06:25
  • @ScottChamberlain I had no idea you could do that! :) I guess you could even use #if DEBUG .... #endif so that it's only done for debug builds, since I assume that's the only time this would be useful. – ProgrammingLlama Feb 28 '17 at 06:28
  • @LiamSavage http://stackoverflow.com/questions/9180638/working-with-appdomain-assemblyresolve-event – ProgrammingLlama Feb 28 '17 at 06:33
1

This is because you have Copy local = true on those references.

Right click on the reference (under the references node in solution explorer) and choose properties. From there, find the Copy local property and set it to false.

Leon Bambrick
  • 26,009
  • 9
  • 51
  • 75