Hi, I have a web application project. I have DLLs that I reference in the project stored in my bin/ folder. Well, whenever I do a rebuild or clean from Visual Studio, it will delete everything in that folder. How do I prevent this from happening?
A:
Can you explain why you have to store it in the bin folder to begin with? i always create a separate folder for example /components where i store all referenced dll's.
Shrage Smilowitz
2010-02-01 20:41:46
idk, bin/ has always just made sense to me. It's the one place where executable binaries are placed. Will moving files out of bin/ cause problems?
Earlz
2010-02-01 20:44:35
@Earlz, you should have a lib directory (some people also like a thirdparty directory) where you place referenced assemblies. Your build script should copy these to the bin directory as required, this allows you to have a clean build.
Paolo
2010-02-01 20:50:46
@Paolo: Visual Studio will copy them to bin automatically if they are referenced from the `lib` folder.
John Saunders
2010-02-01 20:57:38
@Earlz: another reason `bin` is not a good idea is that `bin` should never be checked into source control. It should be possible to restore all "source" files to do a clean build. That would never include your files in `bin`.
John Saunders
2010-02-01 20:58:27
It's not like our generated binaries are in bin, bin/ is just has our third party assemblies. I see no problem with it.
Earlz
2010-02-01 21:05:04
Where are your generated binaries?
John Saunders
2010-02-01 21:20:42
@Earlz - being able to do a clean build into an empty directory shows you have got all the components correctly rounded up and assembled, this helps enormously when it comes to packaging and deploying to another system (e.g. system test) as you won't be left chasing down that elusive "works on my machine" bug from the DLL you forgot to copy
Paolo
2010-02-01 21:22:04
+2
A:
I'll stay away from asking the 'why' question and just state the how. Mark the files as read only and VS shouldn't delete them.
billb
2010-02-01 20:47:15
-1 only because you should not be storing your DLLs in the bin directory, even if there is a way to make it work.
Jason Berkan
2010-02-01 21:50:05
That doesn't mean we should not answer the question. Let's save the holier than thou for a place where debates like this are proper.
billb
2010-02-02 13:27:20
Actually I was more concerned with the fact that the answer was both accepted and the highest voted (at the time I downvoted it). You are correct that it is a valid answer to the problem given.
Jason Berkan
2010-02-02 22:16:53
+3
A:
Do not put anything into bin yourself. bin is the target folder for binaries - it is not a source folder for binaries.
Create yourself a lib
folder or something like that to put your third-party binaries into. You might even name it "Third Party Binaries", since not everyone knows that "lib" means the same thing. Make your references to the binaries in this folder, and Visual Studio will copy them into bin
when necessary (including on a rebuild).
John Saunders
2010-02-01 20:49:29