Ray
Ray

Reputation: 780

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?

Upvotes: 5

Views: 3411

Answers (4)

DOUMBIA Mamadou
DOUMBIA Mamadou

Reputation: 390

First, install a nmp configuration file, and add bootstrap like in bower.json and save. Visual studio will download it. This is available for all packages. You can find the installed packages in the nmp node under the dependencies node of your project. Find more informations here

Upvotes: 0

Alexan
Alexan

Reputation: 8637

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.

Upvotes: 1

Mark Redman
Mark Redman

Reputation: 24535

Add the "Package Installer" and "Bundler & Minifier" Extensions into Visual Studio (both created by Mads Kristensen)

Use the Package Installer to install client libraries using "npm" which is widely supported.

This downloads the files to a node_modules folder in the root of your web project.

Use Bundler & Minifier to copy/bundle/minify as you like for dev and/ or production from the node_modules folder to where you want them in the wwwroot folder.

Upvotes: 0

ssmith
ssmith

Reputation: 8962

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.

Upvotes: 2

Related Questions