views:

121

answers:

3

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
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
@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
@Paolo: Visual Studio will copy them to bin automatically if they are referenced from the `lib` folder.
John Saunders
@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
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
Where are your generated binaries?
John Saunders
@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
+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
-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
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
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
+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
+1 The only correct answer to this problem.
Filburt