dotnet-add-reference(1)

πŸ“¦
version 9.0.17 Β· 4 versions
, in fedora 43, ubuntu questing

πŸ’– dotnet-add-reference(1) β€” the .NET Documentation glow-up πŸ’–

okay bestie, welcome to dotnet-add-reference(1), straight out of the .NET Documentation ✨

this one applies to: βœ”οΈ .NET Core 3.1 SDK and later versions 🌈

✨ NAME ✨

dotnet-add-reference β€” adds project-to-project (P2P) references πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

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

dotnet add reference -h|--help

🌸 DESCRIPTION 🌸

dotnet add reference is literally the convenient little shortcut for adding project references to a project πŸŽ€ After you run it, the <ProjectReference> elements get added to the project file. no cap.

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

πŸ’œ Add a reference to an assembly that isn't in a project

not me telling you the tea: there's no CLI command to add a reference to an assembly that isn't in a project or a package 😭

but you can still do it yourself, bestie β€” just edit your .csproj file and add markup like this:

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

πŸŽ€ ARGUMENTS πŸŽ€

  • PROJECT

specifies the project file πŸ“ if you don't specify it, the command goes looking for one in the current directory πŸ”

  • PROJECT_REFERENCES

the project-to-project (P2P) references you wanna add πŸ’– specify one or more projects. 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 targeting a specific framework, using the TFM format 🎯
  • -?, -h, --help β€” prints out a description of how to use the command πŸ™‹β™€οΈ
  • --interactive β€” lets the command stop and wait for user input or action, like for completing authentication πŸ” available since .NET Core 3.0 SDK ⭐

πŸ”₯ EXAMPLES πŸ”₯

  1. add a project reference:
dotnet add app/app.csproj reference lib/lib.csproj
  1. add multiple project references to the project in the current directory:
dotnet add reference lib1/lib1.csproj lib2/lib2.csproj
  1. add multiple project references using a globbing pattern on Linux/Unix:
dotnet add app/app.csproj reference **/*.csproj

and that's the whole vibe, bestie 🫢 go add those references, you're gonna eat πŸ’…βœ¨

this page was served fresh on 2024-10-02 as part of dotnet-add-reference(1) from the .NET Documentation set πŸŽ€ tysm for reading, mwah 😘

πŸ“¦ where this page comes from
  • fedora 43: dotnet-host 9.0.8-1.fc43 Β· 0BSD AND Apache-2.0 AND (Apache-2.0 WITH LLVM-exception) AND APSL-2.0 AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause AND BSL-1.0 AND bzip2-1.0.6 AND CC0-1.0 AND CC-BY-3.0 AND CC-BY-4.0 AND CC-PDDC AND CNRI-Python AND EPL-1.0 AND GPL-2.0-only AND (GPL-2.0-only WITH GCC-exception-2.0) AND GPL-2.0-or-later AND GPL-3.0-only AND ICU AND ISC AND LGPL-2.1-only AND LGPL-2.1-or-later AND LicenseRef-Fedora-Public-Domain AND LicenseRef-ISO-8879 AND MIT AND MIT-Wu AND MS-PL AND MS-RL AND NCSA AND OFL-1.1 AND OpenSSL AND Unicode-DFS-2015 AND Unicode-DFS-2016 AND W3C-19980720 AND X11 AND Zlib
  • ubuntu questing: dotnet-host-9.0 9.0.17-0ubuntu1~25.10.1
  • ubuntu questing: dotnet-host-9.0 9.0.9-0ubuntu1
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms