Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

New tools in ASP.NET Core template: gulp and bower

$
0
0

When I create a new ASP.NET Core project in Visual Studio, I get a number of things that were not available in earlier ASP.NET versions. These are additional tools that seem to be popular with other web developers. I mean gulp, grunt and bower. I have never heard of them before getting in touch with the new project templates so I need to learn what they are and how to properly use them, or whether not.

grunt doesn't seem to be used so it's not much of a concern now. As I understand it, gulp is some sort of task runner. It needs configuration (which doesn't seem to be set in the project template) and Visual Studio's own new Task Explorer panel can somehow visualise these tasks and integrate them with the build process. I've never seen gulp in action so I'm wondering whether it is actually being used at all.

bower must be some sort of package manager, like NuGet, but for client-side resources like JavaScript or CSS files. It has an online repository comparable to the NuGet gallery, but it's not up to date and contains almost no information about a package. For example, the jQuery package is a few versions and major versions behind what's available from the jQuery.com website directly. The package link on the bower website simply points to the source code. bower might have some package restore feature but it's not documented.

So my environment is this: I have a .sln solution file with an ASP.NET Core project and some other .csproj C# projects. I use Visual Studio 2015 to develop and MSBuild with the .sln file to build things from a CI server. I also call NuGet package restore in advance so that everything is in place for the build. All of this may run on a build server without Visual Studio installed.

I understand that I need to run NuGet.exe to restore packages. NuGet packages are downloaded into and referenced from a separate directory that is completely managed by NuGet. This directory is not checked into version control to save space in the repository size. NuGet.exe is also a separate program that must be downloaded by my build preparation script, which then runs NuGet and MSBuild.

Now where do gulp and bower come from, and where do they live? Will these tools be downloaded by the MSBuild process in order to do their work? Or will I have to install the full Visual Studio to have them available? If they are downloaded, where are they stored on disk? How is that bower package restore triggered? Will it just work if I delete the wwwroot/lib directory from version control? Or will it do nothing and these files must be checked in, unlike NuGet packages? If there's some kind of restore on build, which directories can I exclude/ignore from version control? What are typical .gitignore patterns for this kind of project structure?

Another feature is bundling and minification. Recently I've read about the BundlerMinifier Visual Studio extension from Mads Kristensen somewhere on a .NET blog. This extension can watch changes on CSS of JavaScript files and immediately bundle or minify them as I save the source file. These files must then be checked into version control because that tool won't be available at build time. The documentation (GitHub readme) says there's MSBuild integration but that's not true for my version, and the screenshots in the documentation are contradictory themselves. (I just have the context menu without "Enable bundle on build", not the other.) How does this extension compare to gulp tasks? Can gulp bundle and minify files itself or will it require additional configuration and separate packages to do the work? I can't find any of this in my project template. Should I use one or the other? How would gulp bundle and minify files at build time, using MSBuild? Will it work at all? Again, if gulp can bundle/minify files on the build server, could I ignore these distributed *.min.css and *.min.js files from version control? Any suggested .gitignore pattern for that, too?

These are a lot of questions that are on my mind at this moment. I feel very lost with this new toolset and I'm seriously considering throwing it all away, removing any gulp or bower I can find in the project, and just manually downloading and checking in jQuery and Bootstrap files into my source tree just like my own scripts and images. At least that's a workflow I fully understand and control. Maybe the BundlerMinifier extension will offer me "Enable bundle on build" if I get rid of "competing" tools…

Can somebody please answer these questions or point me to resources explaining all this stuff?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>