How to use Project-to-Project references in nuget packages with .NET Core CLI SDK

Out of the box the dotnet pack command (from the .Net Core CLI) treat every project in the Visual Studio solution as its own Nuget package.

Project-to-project references aren’t packaged inside the project. Currently, you must have a package per project if you have project-to-project dependencies. - .NET Core CLI Docs

Today i learned that if you add PrivateAssets="all" to the ProjectReferece in the .csproj file, these project will be included in the Nuget package, instead of marked as a dependency.

This only works for .NET Core or .NET Standard build with the .NET Core CLI and not .Net Framework build with MSBuild.