dotnet-add-reference(1)
π 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 π₯
- add a project reference:
dotnet add app/app.csproj reference lib/lib.csproj
- add multiple project references to the project in the current directory:
dotnet add reference lib1/lib1.csproj lib2/lib2.csproj
- 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