Using MSBuild from the command line

Now that the holidays are over, here’s some hardcore tweakery for Visual Studio 2005 developers. Visual Studio 2005 includes a completely new build system based on XML build files and a standalone build utility called MSBuild. Visual Studio project files are in fact MSBuild files. Open them up in a text editor and you’ll see that they begin like this:

<Project DefaultTargets=”Build” xmlns=”″>

You can also build entire solutions from the command line. Just open up a Visual Studio 2005 command prompt (an easy way of setting up the correct path and enviromental variables), navigate to the project directory, and type:

msbuild yourapp.sln

This is NOT dependent on Visual Studio, since MSBuild is actually part of the .NET Framework redistributable package. This means you can take your project files and build them on machines that don’t have Visual Studio installed, which can be handy for servers.

But what if you want to edit the solution build file? Curiously, solutions are defined in .sln files which are not msbuild files. When you run MSBuild against an .sln file, it actually creates a new in-memory build file for compilation, making it hard to edit.

This is where the tweak comes in. If you define the enviroment variable msbuildemitsolution, then MSBuild generates the solution build file and leaves it there for you to edit. It is given the name yourapp.sln.proj. For the next build, you can run msbuild against this file directly, thus incorporating any manual changes.

Why it works like this, who knows? Still, it’s an intriguing tip and as you can guess I didn’t discover it by accident. I got it from Sayed Ibrahim Hashim’s excellent blog. He is the author of the MSBuild/ClickOnce book Deploying .NET applications. I haven’t seen the book, but I recommend the blog if you want to know more about msbuild; the book is likely good as well.

Technorati tags: , ,

The loudness wars: why many CDs sound bad

It’s tough being an audiophile. Once upon a time, there were LPs. They could sound good, but suffered from surface noise, scratches, wear and tear, and inner groove distortion. Enter the CD. Perfect sound forever, said Philips. It fixed all the aforementioned defects.

Trouble is, to some ears there were CDs that didn’t sound as good as the LPs they replaced. Various theories were put forward as to why that might be the case. Some claimed that 16 digital bits were insufficient. Others said that early CDs were being made from LP cutting masters, which sound artifically bright to compensate for limitations of vinyl, or that engineers could not kick bad LP-based habits. The answer was to wait for improved remasters.

Twenty-five years on from the arrival of CD, and remasters are abundant. And guess what: audiophiles are now seeking out those early CDs, saying how much better they sound. Others are digging out their old LPs. It’s all to escape a recent, insidious trend in digital mastering, often called the loudness wars, but more accurately described as excessive compression.

Compression is a technique for reducing the dynamic range of a piece of music by boosting the quieter passages and perhaps limiting or clipping the louder passages. The result is that the music sounds louder when played with the same settings as less compressed music. That doesn’t mean it is actually played louder, as listeners simply turn down the volume to compensate. Unfortunately excessive compression also robs the music of its detail and makes it sound unnatural. This is the reason many of today’s hits sound worse than recordings made thirty years ago and released on LP. Along with the public’s appetite for lossy-compressed audio such as that sold by Apple’s iTunes music store, it’s enough to drive audiophiles to despair.

A picture paints a thousand words so … here’s the wave form in Audacity (an excellent freeware sound file editor) for the Who’s classic Pinball Wizard, as it appeared on a 1990 CD from the audiophile label Mobile Fidelity:


In 2004 Tommy was remastered for a deluxe edition. The image below shows the same song, same mix, but it sounds louder. That’s partly because the audio engineer has maxed out the volume available on a CD (not in itself a bad thing), but also because the sound is more compressed. The waveform is tending more towards a solid block with straight edges top and bottom. Still, this level of compression is mild as you will see in a moment.

What follows is a much worse example. It’s McFly and the band’s recent single Star Girl. I’ve noticed that highly compressed/loud mastering is common on material aimed at a young pop audience. Other examples I’m aware of are CDs from Lily Allen and from the Arctic Monkeys. The straight edges likely indicate clipping of the louder sounds as well as boosting of the quieter ones. 

This doesn’t apply to next illustration, which is even more severe. It’s the song Pablo Picasso from David Bowie’s 2003 CD Reality. Even looking at these images is enough to make your ears hurt.

Let me emphasize: if you purchase an overly compressed CD, there is nothing you can do to fix it. Turning the volume up and down, or fiddling with an equalizer, will do nothing to restore the detail or fix the unnatural sound.

Why I am writing here on a subject that has been well covered elsewhere? Simply because I feel strongly about it; these over-compressed CDs are sub-standard products.

It’s unlikely that the average person will recognize the problem for what it is. The effect is more subtle; the sound is fatiguing and the CD will likely be played less frequently; fewer copies will be bought.

I’m doing my bit to publicize the issue. As awareness is raised, there must be some chance that the industry will moderate its practice and that standards will improve.


Youtube video with excellent visual and audio explanation – view this if you don’t get the point yet

Discussion of the above on Steve Hoffman’s audio forum – Hoffman is a respected mastering engineer

Wikipedia article on The Loudness War

Complaint from despairing David Bowie fan

Article: Everything louder than everything else

Article: Imperfect sound forever

Barry Diament: Declaring an end to the loudness wars – an audio engineer’s perspective