1

I have a Web API project in .NET core. It has a dependency to Microsoft.AspNetCore.App by default.

I need to access some of the package's dependencies in another class library project that I have. Let's say that I need Microsoft.Extensions.Configuration.Abstractions.

Visual studio suggests that I add a reference to my DLL downloaded by nuget in my packages folder. Is that a valid approach? Or is it better to add it as a separate nuget package for the class library? If the latter approach is preferred, how do I know which version I should use?

1 Answer 1

1

You should add a reference to the NuGet package containing the API you want from the other library you're writing. Which version should you choose? It's up to you. One common philosophy says to reference the lowest version that has the API you want so that your library will be usable from the most number of places. Anyone referencing your library can still "lift" the version to a higher version and there are no issues with that in general (the exception is when there are breaking changes).

Do not reference the DLL directly from disk. This causes problems such as making source control more complicated (different machines have different paths), and making dependency management more complicated (no easy way to update dependencies).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.