Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Bootstrap in an ASP.Net Core 2.0 Application?

I know that Bower is not recommended to be used with ASP.Net Core 2.0. Instead, I used NuGet to download Bootstrap dependency into my project. Therefore, I can't reference the files in my Layout view like I used to do with Bower using:

<link href="~/lib/bootstrap/dist/css/bootstrap.css" rel="stylesheet" />

I am trying to use NuGet to get a cleaner code. However, I can't seem to be able to reference this package in my project. Anyone has an idea how to use/reference bootstrap installed through NuGet in an ASP.Net Core 2.0 application?

like image 943
Ray Avatar asked Oct 17 '22 19:10

Ray


2 Answers

In .NET Core, Nuget is no longer suitable for deploying client files. This was a design decision made by Microsoft. Instead, you can use any of a host of client build/deploy tools like npm, or my preference is to simply link to the libraries you need st a CDN location. This eliminates deployment issues and offers better performance for your users.

like image 70
ssmith Avatar answered Oct 21 '22 07:10

ssmith


In Visual Studio 2017 Preview, you can use Library Manager:

Library Manager (“LibMan” for short) is Visual Studio’s experimental client-side library acquisition tool. It provides a lightweight, simple mechanism that helps users find and fetch library files from an external source (such as CDNJS) and place them in your project.

Soon it will available in VS stable version.

like image 43
Alexan Avatar answered Oct 21 '22 07:10

Alexan