0

I'm trying to use Bootstrap in my ASP.NET MVC5 project (I'd like to use .NET 5, but Visual Basic is not fully supported yet.)

I installed the latest NuGet package, but no folders/files were added to my project—only the package itself under the References node.

I found this extensive answer, but it's somewhat dated and it addresses a project architecture of ASP.NET Core. I added the suggested Package.json file, but no folder node_modules was added anywhere in my project.

How do I get started using the Bootstrap NuGet package in my MVC5 project?

--EDIT--

I'm using PackageReference, not Packages.config.

Rena
  • 30,832
  • 6
  • 37
  • 72
InteXX
  • 6,135
  • 6
  • 43
  • 80

1 Answers1

6

For Bootstrap is a client-side library,If you download by Nuget Package Manager, you can find it in the %UserProfile%\.nuget\packages directory. You could copy and paste it to your project.

Actually I suggest you could use LibMan for client-side library.

Here is the steps you could follow:

  1. Create the folder wwwroot/lib;

  2. In Solution Explorer, right-click the project folder in which the files should be added. Choose Add > Client-Side Library.

  3. Search for bootstrap@5.0.2 like below:

    enter image description here

  4. Click the Install button to download the files.

Reference:

Use LibMan with ASP.NET Core in Visual Studio

Note:

The js and css are in wwwroot/bootstrap/dist/.

Rena
  • 30,832
  • 6
  • 37
  • 72
  • Very good, thank you. That works. A clarification: when you point out the `dist` subfolder, are you saying that those are the only files I'll need. If its two sibling folders (`js` and `scss`) aren't necessary, I'd like to skip them to reduce project bloat. – InteXX Jul 13 '21 at 20:21
  • 1
    Hi @InteXX, js and scss contains other plugin which is in bootstrap. If you do not want these plugin, you could check the step 3 to choose specific files(see the picture). – Rena Jul 14 '21 at 01:34
  • I see that this creates a ```libman.json``` file in my project. When a new nuget version will be released, do I just need to update the version in that file, or do I need to delete the current ```wwwroot/lib/bootstrap``` folder and re-create it with ```Add > Client-Side Library```? – Kappacake Apr 07 '22 at 18:40
  • 1
    Hi @demonicdaron, Yes, just update the version in libman.json. – Rena Apr 08 '22 at 01:36