dotnet-reference-add(1)

📦
version 11.0.0~rc3 · 2 versions
, in alpine 3.24, centos-stream 10, centos-stream 9, fedora 43, fedora 44, nixpkgs unstable, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

💖 NAME 💖

dotnet-reference-add — adds project-to-project (P2P) references. that's it, that's the whole job bestie 💅

oh and real quick, the manual name is dotnet-reference-add(1) from the .NET Documentation — consider this your official welcome 🫶

This article applies to: ✔️ .NET 6 SDK and later versions
bestie READ THIS before you type anything: if you're on .NET 9 SDK or earlier, you have to use the "verb first" form — that's dotnet-add-reference — instead. the "noun first" form (the one this whole page is about) only showed up in .NET 10. for more info, go look up More consistent command order. periodt.

✨ SYNOPSIS ✨

dotnet reference add reference [-f|--framework <FRAMEWORK>]
     [--interactive] <PROJECT_REFERENCES> [--project <PROJECT>]

dotnet reference add -h|--help

🌸 DESCRIPTION 🌸

okay so dotnet reference add is literally the convenient little shortcut for adding project references to a project. you run it, and boom — the <ProjectReference> elements get added to your project file. main character behavior tbh 👑

<ItemGroup>
  <ProjectReference Include="app.csproj" />
  <ProjectReference Include="..\lib2\lib2.csproj" />
  <ProjectReference Include="..\lib1\lib1.csproj" />
  <ProjectReference Include="..\lib3\lib3.fsproj" />
</ItemGroup>

🦋 Add a reference to an assembly that isn't in a project 🦋

ngl there is no CLI command to add a reference to an assembly that isn't in a project or a package. sad but true 😭 but you can do it yourself — just edit your .csproj file and add markup kinda like this:

<ItemGroup>
  <Reference Include="MyAssembly">
    <HintPath>.\MyDLLFolder\MyAssembly.dll</HintPath>
  </Reference>
</ItemGroup>

💜 ARGUMENTS 💜

  • PROJECT — tells you which project file to use. if you don't specify one, the command goes looking for one in the current directory. it will find it, she's resourceful 🧚
  • PROJECT_REFERENCES — the project-to-project (P2P) references you wanna add. give it one or more projects, go wild. glob patterns (https://en.wikipedia.org/wiki/Glob_(programming)) are supported on Unix/Linux-based systems 🌈

🎀 OPTIONS 🎀

  • -f, --framework <FRAMEWORK> — adds project references only when you're targeting a specific framework, using the TFM format.
  • -?, -h, --help — prints out a description of how to use the command. your little help bestie fr fr.
  • --interactive — lets the command stop and wait for user input or action. like, for example, to complete authentication. available since .NET Core 3.0 SDK. 💖

🔥 EXAMPLES 🔥

  1. add a project reference:
dotnet reference add lib/lib.csproj --project app/app.csproj
  1. add a compatible .NET language (for example, F#) project reference — and this one works in both directions 🫶:
dotnet add app/app.csproj reference lib/lib.fsproj
  1. add multiple project references to the project in the current directory:
dotnet reference add lib1/lib1.csproj lib2/lib2.csproj
  1. add multiple project references using a globbing pattern on Linux/Unix:
dotnet reference add **/*.csproj --project app/app.csproj

and that's the whole page, you ate it 💅✨ this was dotnet-reference-add(1), dated 2025-10-30 — go add those references, bestie, the project file is waiting for you 🌸🦋💖

📦 where this page comes from