0

I'm triying to make a mvc5 project with global dependencies. I just found I can use bower with nuget package manager: How to use Bower (installed from nuget) in Visual Studio?

But I can´t make it work in the build process, and the whole documentation i found are examples with grunt/gulp.

In the major documentation of this project is inactive, because vs 2015 is going to make an official support (I have 2013).

Is possible run bower without grunt/gulp?

Is possible to resolve bower dependencies in a build action?

Community
  • 1
  • 1
vmariano
  • 473
  • 2
  • 19

1 Answers1

1

Yes, you can use bower without grunt and have the visual studio/TFS build do the packages installation. After you install npm and bower, you create your bower.json file in your web application by running in the command line (don't add it from visual studio because there is a problem with the default encoding)

bower init


and then add the newly created bower.json to your project files. Then you edit your csproj and add the following lines:

<Target Name="BeforeBuild">
   <Exec Command="bower install" />
</Target>

This command will create, if needed, at every build, the folder bower_components, you just need to make sure every development machine has bower installed including the build machine. And you will be able to reference all needed files from bower_components (and make sure you don't deploy the whole folder).

Liviu Costea
  • 3,624
  • 14
  • 17
  • mmm, this work also for add the folders to the project after the bower install? – vmariano Jul 08 '15 at 17:02
  • 1
    No, it will not. You need to do somethng else to update your .proj file, a powershell script could work and you can add one more line in the BeforeBuild target to call that script after the bower install. But I don't think it is a good idea to add them to the project, because you will need to check them in to your source control and it is a lot of stuff there you don't need. Just running bower install and having the bower.json in your project it will always recreate the bower_components folder, at least this is what we do. – Liviu Costea Jul 08 '15 at 17:56
  • Ok. I think is more easy using outside of visual studio than handle the whole workarround. Thanks. – vmariano Jul 08 '15 at 18:05