Lib dependencies in C#?

Asked

Viewed 108 times

1

I’m making a C# lib to use in my projects and not always have to rewrite. but as I do with Lib dependencies?

Example:

I made a lib to use Google Drive and has the name lib.GoogleDrive but you need to go along:

Google.Apis.Auth.dll
Google.Apis.Auth.Mvc4.dll

What would be the smartest way to use lib?

Add the project of lib on the project that will use it or routine to publish my DLL with the DLL addictive?

or

Use Nugget and package with dependencies?

  • 1

    I believe that the Nuget serve better for your case. You assemble your package with all dependencies and when downloading the package comes all right

1 answer

0

The correct is the following:

Do your Lib particular and add the dependencies to your project, after that your project to work needs the dependencies to be present, but each library maintainer is responsible for its update, ie if a dependency has been added and it is updated its lib also needs to happen this update (is not mandatory, but for reasons of bugs and fixes it is good to keep projects up to date) and a new publication with these changes should take place.

Summarizing each project and its updates is the responsibility of the library maintainer and are independent.

In the Visual Studio 2017, for example it is easy to make libraries and add dependency packages, for example:

inserir a descrição da imagem aqui

in this example library has a dependency with the package Newtonsoft.Json, your project depends on it to work, but, are projects maintained by different users and each receives updates according to their needs.

To configure the generation of this package click on the project with the right button and the properties menu opens the following screen:

inserir a descrição da imagem aqui

and click select the item Generate Nuget package on build for generation of the package and its dependencies when the project is generated.

inserir a descrição da imagem aqui

Opening this package on Nuget Package Explorer checks that dependency has been added as expected.

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.