Should nugets installed for library project also be installed to the
application project?
This is up to you. Of course, adding the nuget package to the main project is not a trouble, it will not cause any problems, it is simple and convenient, but when you pay attention to the following points, there is no need to add the nuget package in addition.
Before all of these, there are two ways to reference nuget packages: packages.config format and PackageReference format.
Packages.config
format uses for the old net framework
projects, while PackageReference
format uses for new sdk style projects(net core
and net standard
).
However net framework projects can also use PackageReference(you can switch by Tools
-->Options
-->Nuget Package Manager
-->General
-->Package Management
), net core and net standard projects cannot use Packages.config
format.
Suggestion
1) If the library project is Net framework
, actually, you should use add the same nuget into the main project, in some cases, these dlls can be copied in your MyApp project's output path,
however, if you still want to use these dlls in code editor, the intellisense will not list it and in this situation, you should install the same nuget package in the main project.
Further, only these two projects are both using PackageReference format(Net Framework
library project with PackageReference and MyApp Net Framework
project with PackageReference)
2) If your library project is Net Standard
(PacakgesReference nuget format), and your MyApp project is Net Framework
with packages.config
, the dlls will miss in the main project. The workaround is to add these node in MyApp.csproj file:
<PropertyGroup>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup>
Then you will get the intellisense in the main project.
-----------------------------------
Or your Myapp project is net framework with PackageReference format and you should not add that node, you can obtain what you want directly.
If MyApp project is Net Core(PackageReference), you do not have to worry about this.
================================
Conclusion
To meet your requirements, you would better use a Net Standard library project, and your MyApp project is best to use PackageReference nuget management format(Net Core
or Net Framework
with PackageReference format).
In addition, you should update your VS to the latest version for better experience in case there are some important fixes. Also, there is a similar issue you can refer to.