The current implementation for excluding development-time dependencies solves most cases and it is useful, however, it does not solve completely the problem. It does not allow to exclude dependencies on other packages of the same solution.
Suppose we have the following situation (see dependencies_example.png):
- A given solution contains three projects, "A", "B", and "C".
- "B" and "C" have nuspec files.
- "A" is dependent on an external package "D".
- "A" contains runtime dependency on package "C".
- "A" contains dependencies on packages "B" and "D", but not runtime dependencies, i.e., we don't want to list them in the nuspec file.
If you want to create a package for "A", there is no way to exclude "B" from the dependencies because it does not appear in packages.config, only "D":
<package id="D" version="1.0" isDevelopmentDependency="true" />
If you run:
NuGet Pack -IncludeReferencedProjects
NuGet will look at the csproj file, it will find a reference to project "B" and then It will include it as a dependency as follows:
<dependency id="B" version="1.0" /> <!-- It has to be removed manually -->
<dependency id="C" version="1.0" />
- It allows to remove project dependencies in the csproj file.
- Or it allows to remove project dependencies in the packages.config.
- Or it uses a separate file to exclude dependencies.