Where to store external DLL files?

C#.NetWpfVisual StudioDll

C# Problem Overview


In my project I'm using some third-party libraries. I include them using the references folder in Visual Studio.

But where should I save the DLL files? They are referenced from a path in the file system, but it would be nice if I can include it into the project. But how?

C# Solutions


Solution 1 - C#

This is what I do:

  • Create a lib folder at the solution level
  • Download and copy all my third-party DLL files into there
  • Reference from the lib folder
  • Put all those DLL files in the source control. I am using Subversion, and I add them manually but this is one-off.

You can also add a solution folder and add them there.


UPDATE 2012-12-19

The answer above was when NuGet was in infancy. FWIW, my approach where we have NuGet items:

  1. Do as above for plain DLL file dependencies (where they don't have a NuGet pkg)
  2. Enable "Package Restore" for the solution
  3. Change packages.config file if needed to lock down the version to a particular package
  4. Do not store the package themselves in the version control system (set ignore for Git, Mercurial, etc.)

I actually use NuGet for managing even internal dependencies and have a private feed.

Solution 2 - C#

Typically, the structure of my projects looks like this (at a minimum):

projectname
   - trunk
       - src
       - lib
   - support
       - docs
   - releases

The trunk folder contains the copy of the source that I am working on right now. Also, there's a directory 'lib', which contains all the third-party assemblies that are referenced by my project.
(I reference the assemblies at that position).

The 'releases' folder contains branches of the trunk. For instance, when v1 is released, a branch is taken of the trunk so that I have a copy of the source code and all its dependencies that is necessary to build version 1 of the application. (This is handy for bugfixes. Fix the bug in that branch, merge the fix to the trunk, rebuild that branch and you have a fixed v1 of your application).

All these things go into source control. (Yes, the referenced assemblies as well). By doing so, it is very easy if another colleague has to work on the project as well. He just gets the latest version from source-control, and he (or she) has everything in place in order to be able to compile and build).

(Note that this is also true if you use something like CruiseControl for continuous integration).

Solution 3 - C#

You should look at NuGet. It's a package management extension for Visual Studio 2010 designed exactly for what you want.

Solution 4 - C#

In the properties window of Visual Studio for the reference to the dll, there is a Property called 'Copy Local' - set this to true, and they'll be copied to your local project's bin directory

Solution 5 - C#

Take a look at NuGet (package manager for Visual Studio)...

> NuGet is a Visual Studio extension that makes it easy to install and > update open source libraries and tools in Visual Studio.

Then read this NuGet doc to get the crème de la crème:

Using NuGet without committing packages to source control

Solution 6 - C#

Do have a look at [Tree Surgeon][1] - Creates a development tree for a .NET project, which can be a good starting point and from there you can improvise.

[1]: http://treesurgeon.codeplex.com/ "Tree Surgeon on Code Plex"

Solution 7 - C#

Personally, I have a folder in my source control for 3rd party DLLs (with a folder for each company, organisation) and reference them from there.

These files are then available for all developers who download the source and can be updated easily.

Solution 8 - C#

To answer this properly you need to differentiate between the environment and working set.

Environment:

  • This is all the tools and libraries required to build your solution.
  • Things in the environment are expected to stay reasonably constant.
  • Things in the environment are usually versioned and you should be able to have multiple versions side by side.
  • Things in the environment are usually licensed.
  • Environment is not under source control.
  • A good example would be Visual Studio.

Working Set:

  • This is basically your source code.
  • It is all the requirements needed to get to your final executable.
  • You shuold expect the working set to change a lot during development.
  • The working set should be under source control.

You need to decide into which category your component fits.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionanonView Question on Stackoverflow
Solution 1 - C#AliostadView Answer on Stackoverflow
Solution 2 - C#Frederik GheyselsView Answer on Stackoverflow
Solution 3 - C#Antony ScottView Answer on Stackoverflow
Solution 4 - C#Dean ChalkView Answer on Stackoverflow
Solution 5 - C#Leniel MaccaferriView Answer on Stackoverflow
Solution 6 - C#abhilashView Answer on Stackoverflow
Solution 7 - C#Jonathon BolsterView Answer on Stackoverflow
Solution 8 - C#NobodyView Answer on Stackoverflow