Search code examples
visual-studionuget-packagedll-reference

Difference between Reference, Template, and a NuGet package?


What is the difference between a NuGet package, a Reference (is reference similar to a tool?), and a template in Visual Studio?

Why do we need them?

What is done / changed in our project when we install each one of them?

Are they dependent on each other in some way? Which one(s) of them are global installs, and which one(s) need to be installed in every project?


Solution

  • Before any comments or misunderstandings: this answer is NOT composed by me, but it was accepted as an answer here, so for the sake of the users trying to find an answer to this, I am literally Copying the answer to your question in this place.

    What is the difference between a NuGet package, a Reference (is reference similar to a tool?), and a template in Visual Studio?

    References are used to pull additional libraries into your project. For example, your colleague develop a library which implement some functions that you wanted. You needn't write it by yourself, just add the dll into your project through add reference. Of course you can add any libraries not it come from third part or from Microsoft. But it won't notice you when the libraries changed or updated.

    NuGet package is the package manager for the Microsoft development platform including .NET. It will help you manage your packages which installed on your project. When the package has new version released, it will notice you to update it. The NuGet client is a tool provide the ability to produce and consume packages.

    Template is similar to a sample project which provides the frameworks based on different type of project. You just need to add your content/functions into this frameworks to implement your requirement. For example, if create a WinForms project, it will reference System.Windows.Forms automatically which contains all stuffs you needed in WinForms project.

    Why do we need them?

    NuGet package and Reference can help us invoke some functions which have been implemented by others or some have been encapsulated by Microsoft. And the Template can help us create a project without build framework by our self. All of them help us save a lot of time when developing a project.

    What is done / changed in our project when we install each one of them?

    Add references in your project, it will let you invoke the functions in these references in your project.

    Install NuGet packages will add the package reference into your project automatically and then you can use the functions the package provided.

    The template will be installed when you install Visual Studio. Most of common templates will be installed. Then you can create a new project through these templates quickly.

    Are they dependent on each other in some way? Which one(s) of them are global installs, and which one(s) need to be installed in every project?

    Reference and NuGet packages need to referenced/installed on a project. But this project can be create through the templates or can be create by customer self. So in some way, reference and NuGet package are dependent on project.

    Templates is global installs and NuGet packages and reference need to be install in every project.