Why Brunch Makes My Life Easier

I wrote earlier about Brunch, which I have adopted recently for managing my web site projects.  In that post, I wrote about switching from ASP.NET to Brunch. In this post, however, I want to lay out a few reasons why I’m using Brunch and how it’s benefiting me.  I attempted to convey these points to a coworker recently, to convince him to use Brunch, but I regret that they didn’t come out as coherently at the time.

So here they are:  why Brunch makes my life easier.

Build system

I did have a build system for my websites before—it was just baked into Visual Studio. I didn’t use it for much, really. In one project, I figured out how to install some nuget packages that compiled Less into CSS at runtime. This was amazing to me at the time, but it was really just the tip of the iceberg.

With Brunch, I’m now writing in Jade, CoffeeScript, and Less. I could easily switch to Stylus or Sass or another wrapper for CSS with a new plugin. Brunch automatically converts these into HTML, JavaScript, and CSS for me every time I save. Once it’s compiled, I can actually go look at the JavaScript to ensure it is correct, and debug it.

Deployment is now just a matter of copying these compiled assets. Brunch puts the entire site in a single folder after compilation. This has reduced the number of moving parts (or at least shuffled them into other areas, e.g. a REST service).

Watch Mode and Server

Brunch can watch your files and rebuild each file as it changes. I am usually using this mode while developing, since it shortens the inevitable cycle of edit-save-reload. It makes it transparent to use Jade or CoffeeScript, since I never have to worry about whether or not it is compiled.

It also has a built-in Express web server that serves the files over HTTP. This saves me the trouble to set up IIS or Tomcat on my dev boxes.

brunch watch --server

Automatic Minification

I never knew I wanted this, but it’s pretty nice. Brunch has a mode to minify Javascript and CSS, so I use that whenever I’m doing a production build. It can even recompile your files as you edit them, with minification. Of course, you could download the underlying tools and run them directly, but Brunch just has it built in and integrated.

brunch build --optimize

JavaScript/CSS Combining

This is pure gold: Brunch can combine multiple JavaScript and CSS files together into a single file, or set of files, per the configuration. I usually have the following: app.js, app.css, vendor.js, vendor.css. While the goal is to reduce the number of requests made from the browser to the server, the real benefit is that I can easily create my HTML file to load these 4 files, and then never worry about my vendor scripts again.

Need to add a new library? Just drop it in the /scripts/vendor folder and it gets loaded by your site! Don’t need it anymore? Delete it from the folder! I no longer have to deal with listing every javascript library I’m using in my HTML files. The only thing I have to do is make sure that libraries that need to load first (e.g. jQuery) are specified as such in the configuration. But for everything else, it’s add and forget, which is exactly how it should be.


I’m sure there are other amazing features and plugins that I should be using and could make the list.  But these are the things that stick out to me every day because they are currently making my life easier. Even if you don’t want to use CoffeeScript or Jade templates, the built-in minification, concatenation, and web server would be compelling reasons alone to consider Brunch.

Why Brunch Makes My Life Easier

Moving From ASP.NET to Brunch

I’ve been working with ASP.NET since the 2.0 days, moving on to ASP.NET 3.5, then finally to ASP.NET MVC 4.0.  But lately, I’ve been using Brunch to build static websites that do everything client-side in JavaScript.

These two technologies are not even comparable:  ASP.NET is a server-side web-framework, whereas Brunch is a build system.  Brunch has many plugins, such as compiling LESS into CSS, or minifying your assets.

At some point, I started feeling like I was misusing ASP.NET, and this uneasy feeling made me start looking for an alternate solution.  I had started on a website using Angular.js, which is a client-side web application framework .  It is generally used for single-page apps, as Angular has its own routing system and can switch “pages” without reloading the browser.

So how was I misusing ASP.NET?  I wasn’t using it for routing or generating HTML.  There were no postbacks or server-side controls.  Basically, I was ignoring 90% of its features and just using the master file to combine header and footer with my single-page app.  I also enjoyed having a project file to organize things, but that’s hardly a compelling feature.

Brunch stuck out to me because all I needed was something analogous to a build system for code.  It combines my JS files, minifies them for production, compiles Coffeescript to Javascript, compiles LESS to CSS, and compiles Jade to HTML.  And those are just the plugins I’m using!

ASP.NET also has code-behind, which can connect to my database and pull out data.  Brunch obviously has nothing similar, as it is just a build system.  Some other web service technology is needed provide data to the client-side service.  I’ve been using Express in Node.js to create REST APIs, but you could use ASP.NET Web Api or any number of other solutions to do this as well.

I’ve seen some alternatives to Brunch, namely Grunt.  I don’t know who would win in that showdown, but I’m more than happy with Brunch.  It is a good fit for my client-side web app development, as it gets things done and getting out of the way.

Moving From ASP.NET to Brunch

Deploying an SSAS Database via Powershell

This is a repost from my older blog, written in May 2009.  It garnered a fair amount of interest (relatively), so I’m keeping it alive here to help as many people as possible.

I’m trying to automate the deployment of a SSAS deployment so it can be handed off easily to another team. Using a combination of XMLA and Powershell scripts, I got it to work. This is with SQL Server 2008 and may not work with other versions.

Here are the steps:

Generate the XMLA script to deploy the database

  1. Build your SSAS project
  2. Open the Analysis Services Deployment Wizard. You can find this in the Start Menu -> Microsoft SQL Server 2008 -> Analysis Services
  3. Select the *.asdatabase file in the \bin folder of your SSAS project
  4. Click through the wizard until it prompts to Create deployment script. Check this option and select a path to save the script to
  5. This will generate a *.xmla file. You can test it by opening it in SSMS and executing it, and it should deploy the SSAS database successfully.

Write a Powershell Script

My script looks a little something like this:

$cwd = get-location
[System.IO.Directory]::SetCurrentDirectory($cwd)
$query = Get-Content $args[1]

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices.Xmla")
[Microsoft.AnalysisServices.xmla.xmlaclient]$xmlac = new-object Microsoft.AnalysisServices.Xmla.XmlaClient
$xmlac.Connect($args[0])
Write-Host ("Connected to " + $args[0])

$xmlResult = ""
$properties = new-object "System.Collections.Generic.Dictionary``2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"
$xmlac.Send($query, $properties)
$xmlac.Disconnect()

Write-Output $xmlResult

It takes two arguments: the server to connect to, and the XMLA script to execute. It runs the script on the server and writes the result back to the shell.

Deploying an SSAS Database via Powershell

Connecting to SQLite through SSIS

This is a repost from my older blog—it was actually my most-popular post since writing in March 2009!  I was working on SQL Server Integration Services, trying to pull data from SQLite.  I found very little information online, and even less combining both SQLite and SSIS together.  The following worked for me in 2009, using SSIS 2008 and whatever version of SQLite was available then.  Hopefully this post continues to be useful!

After much investigation, I managed to access a SQLite database in SSIS through ODBC. Here are my steps:

  1. Go here: http://www.ch-werner.de/sqliteodbc/. Download the Current Version of sqliteodbc.exe
  2. Run this program, and it will install ODBC drivers for SQLite on your computer
  3. Open Administrative Tools and then Data Sources (ODBC)
  4. In the User DSN tab, click Add…
  5. Select the SQLite3 ODBC Driver and click Finish
  6. On the next page, type in a name for the Data Source, and pick the database file using the Browse button.
  7. Switch to SSIS and create a new Data Flow
  8. In the Data Flow, right-click in Connection Managers and create a New ADO.Net Connection
  9. Click Create to create a new Data Connection
  10. Select .Net Providers\Odbc Data Provider from the Provider dropdown
  11. Select the ODBC connection created previously, and Test Connection
  12. You can then add a ADO NET Source, connect it to that Connection, and load data from a table.

I hope this help somebody looking for the same thing as me.

Connecting to SQLite through SSIS