Add/Remove References Using dotnet CLI Tool

In the latest update made to the .NET Core tooling, dotnet new and add command has undergone significant changes in the usage and options available for the command. You can read more about the updates here in the official blog. In this current update it replaces the dotnet add p2p command with a new syntax.

Adding a Reference

Syntax

dotnet add reference <path to project file>

Usage 

dotnet add reference ..\Lib\Lib.csproj

When you execute the following command it will get added to the project and if look at the csproj file of the project to which the reference is added you will see the entry for it

Remove a Reference

Syntax

dotnet remove reference <path to the proj file which needs to be removed>

Usage

dotnet remove reference ..\Lib\Lib.csproj

To remove the referernce we will use the dotnet remove reference as shown below.

Documentation

To view the help documentation for the above two commands, just add --help switch in the command as shown below.


No Comments

Add a Comment