Conditional Reference

Visual Studio is a tremendous IDE. It makes the life of every .Net developer so much easier…if you develop on a Windows machine and have an MSDN License. For those who don’t, there is Monodevelop, an IDE developed/maintained by Xamarin, which I have been using when working on my Mac.

One of the open source projects I have been working on with a buddy in recent weeks is an ASP.NET MVC 3 application, which I hope to showcase as soon as more interesting features get implemented. As of yet, monodevelop does not fully support ASP.NET MVC 3 due to some proprietary code associated with it, hencewhy I have done most of my developement on my windows machine…until now :D.

In order to run MVC 3 on a mac, you need to have some specific .NET libraries on your output folder. These libraries include *System.Web.Mvc*, *System.Web.Webpages*, and *System.Web.Razor*. You could certainly copy them from the GAC to your lib folder and reference them in your project which you could then use both on Windows and unix-like systems…but there’s a more elegant (and easy) way of solving this issue.

You can specify conditions on your poject pertaining to what library to reference based on your configuration file. In my case, here’s what I had to do:

Now, on my Mac or my Ubuntu virtual machine, I can compile and run the website using the ‘Mac’ configuration; while I can continue to use adequate reference on my Windows machine the way the guys at Big Mike intended it.

Advertisements
Conditional Reference

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s