3

In ASP.Net core 1 projects there was a packages.json where you would manage packages like bootstrap but this file is not in my asp.net core 2 mvc project but the project came with bootstrap. I have checked the Manage Nuget and Manage Bower but both of them do not show bootstrap as an installed package. Infact they don't show anything but ASP.net core. How do I remove bootstrap from the project? And in turn how to I manage the pre-installed copies of jQuery?

3 Answers 3

3

You can remove any unnecessary CSS/Javascript from /path/wwwroot/css and /path/wwwroot/js, but the main directory for bootstrap/jquery is generally /path/wwwroot/lib

As for auto install/updating this, that is handled by Bower which is located in bower.json and can be removed by simply removing those dependencies.

Clarity edit:

Inside of project_folder/Views/Shared/_Layout.cshtml, remove:

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

and

<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css"
          asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
          asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />

Javascript at the bottom:

<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>

and

<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.0.min.js"
        asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
        asp-fallback-test="window.jQuery"
        crossorigin="anonymous"
        integrity="sha384-K+ctZQ+LL8q6tP7I94W+qzQsfRV2a+AfHIi9k8z8l9ggpc8X+Ytst4yBo/hH+8Fk">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js"
        asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
        asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
        crossorigin="anonymous"
        integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa">
</script>

Inside project_folder/wwwroot/lib folder, remove all bootstrap folders, jquery folders.

Sign up to request clarification or add additional context in comments.

2 Comments

There is no bower.json file to manage these. I know I can just delete the files but I want to make sure they are fully removed and I know things installed by packages should not just be removed but completely uninstalled
I'll edit my response to be more clear, but I gave you the places that you need to go to fully remove Bootstrap even without Bower.
0

You can manage your client side packages with Bower in ASP.NET Core by editing the bower.json file - see: https://learn.microsoft.com/en-us/aspnet/core/client-side/bower

example of bower.json file in asp.net core

NOTE: Just be aware that bower is not supported anymore will be depreciated in asp.net core shortly.

https://github.com/aspnet/Home/issues/2086

https://wildermuth.com/2017/11/19/ASP-NET-Core-2-0-and-the-End-of-Bower

2 Comments

In the new template there is no bower.json file and, as stated, when I do "Manage Bower" these do not show up.
That was a brand new project that I created to take the screenshot for you. Can you compare your project to this screenshot: imgur.com/a/7s4Rv
0

I think the better way for you is to create a empty project. There is no file in wwwrot folder and no items installed. Then after creating necessary files for your project you chose the best alternative for front-end framework like bootstrap or jquery.

Checkout this link: Client-side development in ASP.NET Core

There you can find the client-side solution may suit you better.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.