How to reference related projects in the same solution when Nuget packages are the required output

I was wondering what is the best approach to link to a project in the same solution. Whether you create a link using the "Add Link" function or "manage the nuget package" and download a specific published version. Each project, in turn, will result in a Nuget package that can be referenced by other solutions.

So, for other solutions it is clear. They create a link using Nuget, but what about links to projects within a project?

+6
source share
1 answer

The best approach is to create NuGet's dependency on a specified project.

Suppose you have two projects in your solution:

Solution | ProjectA | ProjectB 

ProjectA has a link to ProjectB, and both are NuGet packages (both have nuspec files). If you want to create a ProjectA package that depends on ProjectB, run in the root of ProjectA:

 NuGet Pack -IncludeReferencedProjects 

Given IncludeReferencedProjects, NuGet will traverse related projects inside the solution, looking for nuspec files (this means that the project is a package). If nuspec, if found, it is added as a dependency.

In this example, he will find the nuspec file in ProjectB and add it as a dependency. When you install ProjectA, ProjectB will also be installed, and it will be added as a link.

+10
source

Source: https://habr.com/ru/post/947411/


All Articles