Going to MIX09, or ASP.NET MVC vs the mighty CMS

Well I’ll be getting on the plane to go to MIX09 in a few hours. I’m really looking forward to it, since there are a lot of ASP.NET MVC talks this year by many .NET people who I have a lot of respect for.

Since I do a lot of CMS development ASP.NET MVC has always a bit of an odd proposition technically. CMSes pretty much always want to enforce their own idea of how to program, which tends to be technically about as advanced as putting SQL statements right on the page so their marketing department can make claims about how easy it is to use if you require practically no advanced functionality. It’s a constant battle to figure out ways of writing maintainable, “good” code within the confines of a CMS’s API, and ASP.NET MVC is definitely one of the tools I’m looking at.

The main problem with integrating ASP.NET MVC into a CMS installation is that almost all CMS like to have a fully hierarchical URL setup; i.e. http://mysite.com/some/long/path/to/rewritten/content.aspx that would match /some/long/path… in the admin interface. The default routing system from what I’ve been looking at won’t really support this setup since what we’re really doing is defining what item in the (dynamically created and modifiable) hierarchy to look at as opposed to a (static, defined in code) controller action to invoke. So I think it’s likely I’d need to implement my own version of routing, but that brings with it it’s own issue that the custom routing then needs to know a lot about the data before passing control off to a controller action to render a page using a specific template renderer (based on the type of page it finds at the location in the hierarchy). I’m still looking around and hopefully can corner one of the MVC guys at MIX and see if they have better ideas :)

Compiling in minimal environments with MSBuild

I think it’s happened to almost everyone: you push web site changes to a dev server, or a staging server, and something breaks. Something that of course only occurs in that remote environment and can’t be reproduced on your development instance with all its nice debugging tools.

Suppose that you track it back to an issue that will require recompiling the site to test it. Sure, you could build it locally and manually copy files every time you need to test…and realize you didn’t quite fix it, but why do that when there’s a better way to recompile a solution without Visual Studio installed: MSBuild.

So what is MSBuild? In short, it’s the build runner that Visual Studio uses every time you build a project. It parses the solution or project file and executes the build commands embedded in the XML. It’s capable of a whole lot, and makes a great tool to automate nightly builds and lengthy push processes. We tend to use Subversion to accomplish build management by keeping the built DLLs under version control and making configuration changes very minimal across environments, so the build and configuration abilities aren’t as awesome when building medium sized websites. It’s the ability to parse and compile a solution that is of great interest.

So how do I use it to compile a solution without having a local copy of Visual Studio? Fortunately, that’s the easy part. Open a command prompt and type this:

C:\my-project-path> C:\WINDOWS\Microsoft.NET\Framework\v3.5\msbuild.exe my-solution.sln
  • You may need to change the v3.5 to the framework version you’re using. You may also need to change Framework to Framework64 if you want to run the 64-bit MSBuild.

Pretty simple eh? That will build the solution using the active configuration from Visual Studio.