Restore bower components for building Visual Studio

I just created my first ASP.NET 5 MVC 6 project in VS 2015. A web application project that goes out of the box.

I realized that the acoustic components are stored in the wwwroot/lib folder. I did an experiment and deleted it. After that, I restored the project, and the components of the bowler were not restored.

Calling bower install manually in the console restored the files.

How can I automatically create bower files for Visual Studio during assembly?

+6
source share
1 answer

I figured out a way to do this, although I don't really like it. I will be happy to accept the best answer.

In the gulpfile.js project, the first line is a comment "

 /// <binding Clean='clean'/> 

Intercepts a Visual Studio Clean event and binds a Clean Gulp task to it. You can connect to other events, for example. After Build I associated it with a task that uses gulp-bower to restore components.

gulpfile.js

 /// <binding Clean='clean' AfterBuild='after_build'/> var gulp = require("gulp"), bower = require('gulp-bower'); ... gulp.task("after_build", function() { return bower() .pipe(gulp.dest(paths.webroot + 'lib/')); }); 

You can see the bindings in Task Runner Explorer : enter image description here

This decision seems rather awkward. I would prefer kpm to do the job.

EDIT

In fact, there is no need to restore packages during assembly. They are restored when the project is opened in VS. However, I do not know what will happen when you update your sources from the code repository.

+3
source

All Articles