From the last sentence of your question and your emphasis on direct links, I feel like I know what you're looking for:
NuGet defines the -IncludeReferencedProjects option to tell nuget.exe how it should handle reference projects as dependencies or as part of a package:
- If the referenced project has a matching
.nuspec file whose name matches the project name, this referenced project is added as an explicit NuGet dependency. - Otherwise, the specified project will be added as part of the package.
I think you are after the first.
Let's simplify the task to its main form: let's say you have a solution in which LibraryA refers to LibraryB directly as a reference to the project. When building a solution, the assembly output from LibraryA copied to LibraryB
~/ β Solution.sln ββββLibraryA β β ClassA.cs β β LibraryA.csproj β β LibraryA.nuspec β ββββbin β β ββββDebug β β β LibraryA.dll β β β LibraryA.pdb β β ββββRelease β ββββProperties β AssemblyInfo.cs ββββLibraryB β ClassB.cs β LibraryB.csproj β LibraryB.nuspec ββββbin β ββββDebug β β LibraryA.dll β β LibraryA.pdb β β LibraryB.dll β β LibraryB.pdb β ββββRelease ββββProperties AssemblyInfo.cs
Customization
For illustration purposes, I will use the [assembly: AssemblyVersion("1.0.*")] Template in my AssemblyInfo.cs files and make a couple of separate assemblies for each project so that my assemblies get several different interesting versions.
Make sure that each project contains a .nuspec file with the same name as the project. This is especially important for the LibraryA project, as this project is referenced by LibraryB . I will do this for both as a good practice. Let's use the basic template for now:
In .nuspec below, the replacement tokens $id$ and $version$ will get their values printed when you run nuget.exe for the .csproj file that was built.
<?xml version="1.0"?> <package > <metadata> <id>$id$</id> <version>$version$</version> <authors>The author... (**mandatory element**)</authors> <description>Your description... (**mandatory element**)</description> </metadata> </package>
Use nuget pack -IncludeReferencedProjects
Now I'm going to run nuget.exe at the command line from the solutions directory ( ~ ) in the LibraryB project:
PS> nuget pack .\LibraryB\LibraryB.csproj -IncludeReferencedProjects -Verbosity detailed Attempting to build package from 'LibraryB.csproj'. Packing files from '~\LibraryB\bin\Debug'. Using 'LibraryB.nuspec' for metadata. Add file '~\LibraryB\bin\Debug\LibraryB.dll' to package as 'lib\net451\LibraryB.dll' Id: LibraryB Version: 1.0.5993.6096 Authors: The author... (**mandatory element**) Description: Your description... (**mandatory element**) Dependencies: LibraryA (= 1.0.5993.7310) Added file 'lib\net451\LibraryB.dll'. Successfully created package '~\LibraryB.1.0.5993.6096.nupkg'. PS>
Generated packages
The above command will create the NuGet LibraryB.1.0.5993.6096.nupkg package with the explicit NuGet dependency on LibraryA.1.0.5993.7310.nupkg .
When you inspect the contents of LibraryB.1.0.5993.6096.nupkg , you will see that the .nuspec generated by nuget.exe will replace all $version$ replacement tokens with those of the actual versions used.
LibraryB : the command above will only create a NuGet package for LibraryB , but it is obvious that you can create a package for LibraryA by simply running it again for LibraryA.csproj
I hope this is what you wanted, or at least sheds light on what you can do.