3

I am trying to setup an MVC project that can make use of the Bower package manager in Visual Studio on a Mac so that it is the same as using it on Windows. I want to add Bootstrap and jQuery into my application.

I have looked at the pre-built projects that come with Visual Studio and can see that they have used bower.json to install packages such as Bootstrap and jQuery into the project. As a result, in the wwwroot file they have a lib file containing all the required dist folders.

enter image description here

I have tried adding the bower.json file into the project with only the 'Bootstrap' reference as shown in the picture above and have set it to 'Content' on the 'Build Actions' tab. (This what the bower.json file is set to in the pre-built project) However, whenever I set the folders 'Build Actions' to 'Content' and try to build the project, I get this error:

enter image description here

Now every time I change the 'EnableCompileDefaultItems' to false and try to save it, I get an 'Access Denied' message.

All the other files such as appsettings.json are also not being added and I cannot find anything on the internet that gives a good walkthrough regarding setting an empty project up...

How can I use Bower in my project or is there another easier way to add third party items such as Bootstrap into the project? I assume it is possible to download the files for libraries such as Bootstrap and jQuery and add them directly into the wwwroot folder? However, I have never done this is a .Net Core application and am unsure of the setup required for the folder structure.

I guess if it comes to it, I can create a pre-built project and delete all the things I do not need, but I think that is a very backwards way of going about it.

Alex Marchant
  • 570
  • 6
  • 21
  • I would edit your .csproj and remove any reference to bower.json there. Also remove the EnableCompileDefaultItems setting in your .csproj. All .json files are Content files by default. There is also some information on the [Microsoft site](https://learn.microsoft.com/en-us/aspnet/core/client-side/bower) about manual setup of bower. There is a `.bowerrc` which you need to specify the wwwroot folder. I would ignore VS for Mac and just use bower on the command line and get that working first. – Matt Ward Feb 25 '18 at 11:52

0 Answers0