views:

687

answers:

5

Often times a developer on my team will create a new Visual Studio project and reference a DLL somewhere on their local machine (e.g., C:\mydlls\homersimpson\test.dll). Then, when I get the project from the source control repository, I cannot build the project because I do not have the referenced dll in the exact same location on my machine.

What is the best practice for storing and referencing shared libraries?

+2  A: 

Best practice I would expect would have Your SC repository include and enforce the relative locations of referenced objects for you (usually via a shared path), so you aren't dealing with this issue directly. The original developer should check in this information.

le dorfier
How not? Do you not include all linkable modules in SCC?
le dorfier
+1 no magic dll's in the magic folder
Greg Dean
Right - "Go directly to dll-hell. Do not pass Go, ..."
le dorfier
A: 

Hello,

If the assembly is not in the GAC, create a directory called dependencies and add all assemblies there. The folder and the assemblies are added to source control. The rule is that given any project in source control, all that is required to build is to do a checkout and build the project (or run some tool that is also checked into the project).

If you add a folder to the solution and add the assemblies to the solution folder, this also provides a visual cue to the devs that indicates what external dependencies are present... all dependencies are in that directory. Relative paths ensure that Visual Studio can locate the references without a problem.

For large solutions, with 20+ projects, this makes life much easier!

HTH

Colby Africa

Colby Africa
+5  A: 

I typically create a lib folder in my project, where I put the referenced dll's. Then I point the reference to the dll in the lib folder. This way, every developer can build the project after retrieving from source control.

If it's a project that was built in house, you could also add that project to your solution.

Travis Collins
This was my first thought, too. The only drawback I see is that if you have a commonly used DLL it'll be in source control in multiple locations for each project that references it.
vg1890
@vg1890: Multiple copies of the dll may be a benefit, it would allow each project to potentially use a different version of the dll
PaulG
A: 

If you check in the actual DLLs into source control, then you can reference them by relative path and all developers will automatically get any dependencies when they next update the project.

Adding a DLL reference by full path would be a developer error just as adding a source file by full path would be an error.

Greg Hewgill
Do you check in your binaries to your source code version control?
grepsedawk
No, not my own binaries. I had assumed the original question was talking about some third party DLL which was not built with the project.
Greg Hewgill
Ok that makes more sense. We do the same thing with third party libraries.
grepsedawk
A: 

Rule of thumb: If the project isn't a part of the solution, reference released dlls from a source controlled /binshare or /lib directory that is under your solution's source control tree. All external dependencies should have versioned DLLs that go in this /binshare directory.

I understand what your co-worker is doing in regards to convenience. However, that developer's approach is diametrically opposed to proper configuration/build management.

Example: If you use the MS Data Application Block as a dependency in your application, you should reference a properly released binary, instead of getting latest from MS's dev source trunk.

Daniel Auger
Is your first sentence written in English? :) Maybe some commas or conjunctions would help me understand it?
Patrick Szalapski
:) I've added a comma to clear it up. Thanks!
Daniel Auger