dotnet-reference-add
Add a project-to-project reference
TLDR
Reference another project from the current directory
$ dotnet reference add [path/to/library.csproj]
Add the reference to a specific project$ dotnet reference add [path/to/library.csproj] --project [path/to/app.csproj]
Add several references$ dotnet reference add [path/to/a.csproj] [path/to/b.csproj]
Limit the reference to one target framework$ dotnet reference add [path/to/library.csproj] --framework net8.0
SYNOPSIS
dotnet reference add project... [options]
DESCRIPTION
dotnet reference add adds a `ProjectReference` to a project file so the referenced project is built and used as a dependency. More than one path can be passed in one invocation.The noun-first form is available in the .NET 10 SDK and later. Earlier SDKs use dotnet add reference, documented as dotnet-add-reference.
PARAMETERS
project
One or more project files to reference.--project project
Project file that receives the reference. When omitted, the command searches the current directory.-f, --framework framework
Add the reference only when targeting this framework.--interactive
Allow the command to wait for input.-h, --help
Show help and exit.
INSTALL
sudo dnf install dotnet-host
sudo pacman -S dotnet-host
sudo apk add dotnet-host
brew install dotnet
CAVEATS
A reference to a project that does not exist, or a cycle between projects, fails at build time. --framework records a conditional reference; other target frameworks of the same project do not see it.
SEE ALSO
dotnet(1), dotnet-add(1), dotnet-add-reference(1), dotnet-build(1), dotnet-restore(1)
