How to Add Font Awesome to an ASP.NET Core Web Application (Core Version 2.0 and higher)

Start Visual Studio

Select File -> New -> Project…

In the New Project window select Visual C# -> .NET Core -> ASP.NET Core Web Application

Select a folder you want to create your project in, enter the project name and solution name

In the New ASP.NET Core Web Application window select the Web Application (Model-View-Controller) application type. Additionally, select the ASP.NET Core 2.1 Version. Click OK to confirm your choice.

After the project have been created, click with the right mouse button on the project name in the solution explorer and select Add -> Client-Side Library…

The Add Client-Side Library dialog will appear

In the Library field enter font-awesome and press Enter

The dialog will show you what files will be installed to what directories. You can choose specific files to install. For that, select the option Choose specific files and mark the files you want to install.

Click Install to install the library

Next, we have to reference the library to be able to make use of it in our views. Open the _Layout.cshtml file and add the following lines within the <environment include=”Development”> <environment> tags

<link rel="stylesheet" href="~/lib/font-awesome/css/font-awesome.css" />

And between the <environment exclude=”Development”><environment> tags add the following line

<link rel="stylesheet" href="~/lib/font-awesome/css/font-awesome.min.css" />

Now, you can use the font awesome in your views, for instance, like that

<i class="fa fa-users"></i>
%d