What is the idiomatic way to handle third party dependencies in .NET and C# that are provided as dlls

66 Views Asked by At

Let's consider that I have a .NET project and that I have to use a library that is not provided through NuGet but as a dll.

folder tree:
-> SLN   
  -> Project 1
  -> Project 2

Let's say that I will reference the library in both projects, but project 2 is also a library and project 1 is my startup project. Where should I store the example.dll in this folder structure in order to adhere to .NET best practices.

1

There are 1 best solutions below

0
On

Place it in a lib folder. This can be under Project 2, but it could also be directly under the solution folder, in case you anticipate you will use the same dll in more projects, or simply want to keep all the library dlls together .

  MySolution.sln
  \Project1
     Project1.csproj
  \Project2
     Project2.csproj
     \lib
        example.dll

or

  MySolution.sln
  \Project1
     Project1.csproj
  \Project2
     Project2.csproj
  \lib
     example.dll

The only difference in Project2.csproj will be wether the file is referenced as lib\example.dll or ..\lib\example.dll.