Use Bower package version numbers in Razor view to support CDN

I use Bower in Visual Studio 2017 to install packages like Bootstrap and jQuery.

In my views, I reference the same libraries using CDN, for example:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css" asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.css" asp-fallback-test-class="glyphicon" asp-fallback-test-property="visibility" asp-fallback-test-value="hidden" /> 

If I changed the version of Bootstrap in Bower from 3.3.7 to something else, I must remember to go into the Razor view and change 3.3.7 to the updated version number.

Should I use Gulp to read the bower.json file and automatically generate a Razor view with the correct Boostrap version number, or is there an easier way to keep Bower and my Razor files in sync?

+7
bower razor visual-studio-2017 .net-core
source share
1 answer

Better to create a package with all your javascript. Combining and Minimizing with ASP.Net MVC

When you update the update, at run time, the binding automatically changes the JS package so that your client receives the latest version.

+5
source share

All Articles