How to use bower packages in Visual Studio 2017

23,807

Solution 1

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"
}

Solution 2

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

Solution 3

As an alternative to the suggestions of manually creating the bower.json file which will start out empty:

  • In Visual Studio right-click the Web Application project and choose Open Command line > Default (CMD), Developer Command Prompt or PowerShell.

  • If you don't have bower installed run the command npm install -g bower in the command prompt (requires npm).

  • Run the command bower init and follow the instructions which will create the bower.json file.

If you answer yes to set currently installed components as dependencies ? and you already have packages installed in the bower_components folder it will automatically add them as dependencies in the bower.json file.

Share:
23,807
shamim
Author by

shamim

Working on Microsoft .NET Technology with over 8 years of industry experience. Responsible for developing and managing several applications build on .NET technology. In my day to day, work needs to maintain a set of well-defined engineering practices developed by me and as well as other developer communities, having knowledge in domain-driven design, design architectural framework, user experience, usability engineering and project management.

Updated on July 05, 2022

Comments

  • shamim
    shamim almost 2 years

    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