LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

dotnet-reference-add

Add a project-to-project reference

TLDR

Reference another project from the current directory
$ dotnet reference add [path/to/library.csproj]
copy
Add the reference to a specific project
$ dotnet reference add [path/to/library.csproj] --project [path/to/app.csproj]
copy
Add several references
$ dotnet reference add [path/to/a.csproj] [path/to/b.csproj]
copy
Limit the reference to one target framework
$ dotnet reference add [path/to/library.csproj] --framework net8.0
copy

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
copy
sudo pacman -S dotnet-host
copy
sudo apk add dotnet-host
copy
brew install dotnet
copy

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

RESOURCES

Copied to clipboard
Kai