Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use bower packages in Visual Studio 2017

Face two difficulties with bower package manager in vs2017

  1. In Visual Studio 2017, can not find any .bowerrc file under bower.json, so how to set the directory property? After Installation via Manage Bower Packages UI, packages store files in bower_components folder

  2. How to use those packages, as in previous versions like VS 2013 write syntax in BundleConfig.cs to manage client packages like below. Now in VS 2017, how to use those packages in a C# Core 2 ASP.NET MVC project?

BundleConfig.cs:

public class BundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/bower_components/jquery/dist/jquery.js",
                    "~/bower_components/jquery-file-upload/js/vendor/jquery.ui.widget.js",
                    "~/bower_components/jquery-file-upload/js/jquery.fileupload.js",
                    "~/bower_components/jquery-file-upload/js/jquery.iframe-transport.js")); 
    }
}

enter image description here

like image 996
shamim Avatar asked Aug 19 '17 10:08

shamim


2 Answers

I had the same issue.

In the same folder as your bower.json file create the file called .bowerrc. Inside it paste:

{
  "directory": "wwwroot/lib"
}
like image 175
Liam Avatar answered Sep 19 '22 10:09

Liam


Right click your project solution -> Add New Item -> select Web on the left -> select Bower Configuration File on the list -> Add

Now you can install new bower package by right click your solution -> manage bower package.

More details below:

enter image description here

like image 25
AnhNguyen Avatar answered Sep 21 '22 10:09

AnhNguyen