visual-studiotwitter-bootstrapnuget

How to install and use the latest Bootstrap in an MVC5 project?


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.


Solution

  • 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/.