Events
17 Mar, 21 - 21 Mar, 10
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
This article applies to: ✔️ .NET Core 3.1 SDK and later versions
dotnet add reference
- Adds project-to-project (P2P) references.
dotnet add [<PROJECT>] reference [-f|--framework <FRAMEWORK>]
[--interactive] <PROJECT_REFERENCES>
dotnet add reference -h|--help
The dotnet add reference
command provides a convenient option to add project references to a project. After running the command, the <ProjectReference>
elements are added to the project file.
<ItemGroup>
<ProjectReference Include="app.csproj" />
<ProjectReference Include="..\lib2\lib2.csproj" />
<ProjectReference Include="..\lib1\lib1.csproj" />
<ProjectReference Include="..\lib3\lib3.fsproj" />
</ItemGroup>
There's no CLI command to add a reference to an assembly that isn't in a project or a package. But you can do that by editing your .csproj file and adding markup similar to the following example:
<ItemGroup>
<Reference Include="MyAssembly">
<HintPath>.\MyDLLFolder\MyAssembly.dll</HintPath>
</Reference>
</ItemGroup>
PROJECT
Specifies the project file. If not specified, the command searches the current directory for one.
PROJECT_REFERENCES
Project-to-project (P2P) references to add. Specify one or more projects. Glob patterns are supported on Unix/Linux-based systems.
-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
Allows the command to stop and wait for user input or action. For example, to complete authentication. Available since .NET Core 3.0 SDK.
Add a project reference:
dotnet add app/app.csproj reference lib/lib.csproj
Add a compatible .NET language (for example, F#) project reference, which works in both directions:
dotnet add app/app.csproj reference lib/lib.fsproj
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
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Events
17 Mar, 21 - 21 Mar, 10
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register now