February 2009


As it stands, Visual Studio does not allow you to explicitly target a framework other than the .NET framework. I cover that in this post, so if you are curious about that, then you may want to go read that first to understand where this post is coming from. But thankfully, Jason left me a comment that pointed me to this post by Jonathan Pobst. It was a big help in researching this post and basically set me on the right path to getting things to where I wanted them.

The goal was to get some Mono project templates working with Mono assemblies and the Mono compiler in Visual Studio. The trick was to do it in a way that would be able to survive upgrades of Mono installations. I think I pulled it off. :) The end result is a series of project templates that you can put in your \My Documents\Visual Studio 2008\Templates\ProjectTemplates\Visual C#\Mono directory that will give you the following New Project options:

mono-project-templates

Notice the Mono option on the left hand side of the dialog and the Mono project types in the right hand side. Yep, that’s the little Mono monkey there too. :)

In order to use these, you are going to have to do a few things:

1.) Download and install Mono. I installed the current release (2.2) to C:\Mono\2.2

2.) Add a MonoPath environment variable and have it point to C:\Mono\2.2\bin

3.) Add a MonoLibPath environment variable and have it point to C:\Mono\2.2\lib\mono\2.0

4.) Reboot so the environment variables will be recognized

5.) Grab the download at the end of this post and unzip it. In it, you will find 3 project templates and 1 file called Mono.CSharp.targets.

6.) Place the 3 project template files (.zip) in the \My Documents\Visual Studio 2008\Templates\ProjectTemplates\Visual C#\Mono directory. You’ll have to create the Mono directory.

mono-project-template-location

7.) Now, grab the Mono.CSharp.targets file and place it in the C:\Mono\build directory. Again, you will have to create the build directory.

8.) Now, fire up Visual Studio and bring up the New Project dialog. You should see something similar to the New Project Dialog above. (Note: If you don’t see the Mono option in the left side of the dialog then you may need to add the Mono directory to the \My Documents\Visual Studio 2008\Templates\ItemTemplates\VisualC#\ directory as well – see here – otherwise, you may only see them at the top level C#.)

9.) Now, go ahead and select one. You will get prompted with the following prompt from Visual Studio. Make sure you select the Load Project Normally option.

mono-project-prompt

That should about do it. You will now be creating Visual Studio projects that reference the MonoPath and the MonoLibPath, so as you upgrade and wish to move from version to version, all you should have to do it change your environment variables and you will be compiling against the latest version of Mono and using the Mono compiler. (Presumably something like C:\Mono\2.4)

Now, some may point out that Mono is binary compatible with .NET so what’s all the fuss? The answer is that they are in different stages of development, so if you target the .NET framework and then try to run on Mono, you may end up with some gotchya’s. For example, a class or method call that is not yet implemented in Mono. Whereas if you target Mono, then you can be pretty assured, when referencing a System.*.dll it will be implemented in .NET. Also, if you use any of the Mono.*.dll assemblies in your projects, you’ll can just drag them around like any other referenced assembly. There are about 20 Mono.*.dll assemblies, so there is bound to be some goodies in there. :)

If you already have Mono installed somewhere, then you should be able to point your environment variables to the relative locations of your installation and you should still be good to go.

 Download.

 music note While writing this, I was listening to "Jane Says" by Jane’s Addiction

DotNetKicks Image

Open source in the Microsoft ecosystem is a new thing, and to be frank, it’s only gaining ground in some areas of Microsoft. We’ve all heard the news reports of Steve Ballmer saying Open Source is Microsoft’s primary threat, among other things. I’m not here to re-hash all that. You either side with Microsoft, Open Source, or you are somewhere in between.

But, I am here to take Microsoft to task on one specific area where it’s open source strategy is sorely lacking, and that is in the funding or sponsorship of open source products built for the .NET platform. To the best of my knowledge, Microsoft does not sponsor any open source projects, yet they fully reap the benefit of open source developers that build on the .NET platform. We help propagate and evangelize the platform. If you take a look at Sun, they are well entrenched in sponsoring and organizing the sponsorship of third-party open source initiatives. That is a huge win for Sun and the Java community.

Microsoft’s behavior on this front has been pretty sophomoric to this point. A good example of this was Oxite. I’m not up for re-hashing all of that, but suffice to say it flops, and instead of sponsoring the project via some third party (to begin with), they build it internally, and then ask the community to fix their mess. The result of that was a pretty quick backlash from the community that said, “Hey, we’ve got jobs, and bills to pay, we aren’t here to clean up your code.” I honestly believe that was a bit of a reality check for Microsoft and the few open source proponents inside of Microsoft. My guess is that they let their ego’s get ahead of them on that one and were taken off guard by the community’s response, which IMHO, was spot on.

The .NET open source community is maturing and they are beginning to see the gaps between Microsoft’s behavior and the behavior of other open source proponents, such as Sun, and they are recognizing that much of what they are seeing is business as usual at Microsoft. Their attention to open source, to this point, has been in an effort to either 1.) Evangelize their platform or 2.) Harness the power of the open source community in an effort to make their products better. Any open source .NET application is firmly in #1, and things like the Enterprise Library fall into #2.

Microsoft has hired a few open source developers from the .NET ecosystem, but I’ve got some pretty un-easy feelings on that. Most of them are heavy bloggers and over the last several months, those developers’ blogs / podcasts have now become an evangelism platform for Microsoft’s latest initiative. The MVC framework is a perfect example of Microsoft failing to sponsor the Castle framework. They make the argument that “our customers want products by us, and only us”, but what their clients really want is stable products by stable companies. A company that Microsoft could be helping to create by sponsoring them like Sun does.

Is it Microsoft’s job to sponsor open source initiatives? No, not really, but there is a huge upside that they are ignoring when deciding against sponsorship, and that is this: they are foregoing the opportunity to have significant growth engines “close to the vest”, ready to be cherry picked, or perhaps just as well is the community good will that would result from such sponsorships. Microsoft really shouldn’t ignore this, as it is their main Achilles heel – lack of goodwill from segments of the community. If they want their development tools to be the tools to develop with and they want Windows to be the platform to deploy solutions on (open source and otherwise), then they need to consider, very carefully, how they expect to achieve that. You’ve got to do more than release open source software, or engage the community in building some open source frameworks; you have to get out in the community and help build the ecosystem that is going to support you over the long term.

 

DotNetKicks Image

In my planning to get ready for Mono development, I’ve been looking at different ways to get up and running. I’ll be putting together a screen cast of this work, all distilled down so hopefully you will be able to avoid some of the pain, musings, and cursing that occur during this process. Although, I can say, from my experience, that this is a characteristic that has served me well professionally: I don’t mind muddling through the uncharted stuff. BUT, it is an enormous PITA, and I can sympathize greatly with those that are not too eager to do it. I also understand it really is a matter of how interested you are in figuring it out; it being the task at hand.

The first thing we have to look at is getting an infrastructure in place that supports our development. In the Windows / Visual Studio world, a lot of that is pretty simple to get running, especially now that VS ships with a built in web server. I have always used IIS as much as possible, but the built in web server works ok for local development.

I’ve got Mono

But in Mono world, we have some different opportunities to extend our development experience. For instance, you can run Mono and Linux in a virtual machine. Here you have several options; you can pull down a Linux distribution, install it to the VM and then install Mono via the Linux Repositories. For those of you just getting into the Linux world, the Repositories are central locations from which you can choose to install other open source software packages. When I read about the Linux Repositories that immediately gave me pause, because that’s a pretty huge win for Linux. Unfortunately, I don’t think Windows could ever execute on anything like that because of the nature of the Windows ecosystem.

Another option is to install the VM from Mono that is a full openSUSE Linux distribution with Mono and MonoDevelop already installed. For those looking for speed in getting up and running, this is probably the best way to get up and running.

In my first attempts, I went with the first route because I was curious to learn some more about Linux and I wanted to see how far the distributions had come since the last time I worked with them – back in 2000.

Well, let me tell you, they have come a long way, baby. ;)

If you’ve got the time or inclination, I highly recommend picking a virtualization software package and running some Linux distro installs and playing with them. So far I have openSUSE, Ubuntu, Ubuntu Server, and I think I have CentOS queued.

But, I do like Visual Studio and I am comfortable with it. I’ve looked at other IDE’s and for whatever reason; I don’t find them as good as Visual Studio. I recognize that may not be the case, it may be my hang up. So, I’ll be actively bouncing around IDE’s to challenge myself a bit on the IDE front. So, I’ve got a bit of a conundrum. I like Visual Studio, and I’d like to continue to develop in it, but I need a setup in my Windows environment that can support my preferred development experience. So, I started digging into how to get Mono running on my host Windows OS and what other tools I will need to support that development process.

My initial take was to look at using the XSP2 web server that is included with the Mono install. This is probably something akin to the web server that is installed as part of Visual Studio. I got things setup and working ok, but it’s a very small application and is not very robust (their words, not mine). For e-commerce I wanted to make sure I had something that was of the same caliber as IIS or better. This brings me to Apache. I’ve installed the Apache HTTP server and the install was painless and all good. I did have to turn off my IIS service because they both wanted to hog port 80. You can probably configure this to be different, and I may yet do that, but I want to “disable” my old habits as much as possible. Sometimes you have to force yourself to learn. :) It looks like I’ll be able to target the Apache HTTP Server for use by Visual Studio as well, since this is in the Project Properties dialog:

VS_WebServer

Finally, I want Visual Studio to use the C# compiler for Mono, not .NET, so I figured I could do that by changing the target framework. My hope was that Visual Studio would allow me to target Mono as the development framework, and use the Mono compiler as part of that targeting process. Alas, that does not appear to be possible at this point:

VS_Target

So, I think I have to dig in a little deeper to find out how to control what C# compiler Visual Studio uses to see if I can change that. Presuming I can, I then need to setup the virtual directories and such in Apache so that my development experience is as seamless as possible. I don’t want to “feel” these changes, but I know there is some work to do to get the development experience to be something close to what I am used to. Note to the VS.NEXT Team – I know you’re using MEF and MSBuild under the covers, so you should be able to allow this pretty easily.

So far, all of this has been pretty painless and has been more of an exercise in “figuring things out” than anything else. The installs have been painless and have caused me no grief. Things appear to be pretty stable so far.

If anyone is going to “walk the walk” with me, I’ll be putting up some screen casts that go into more detail on all of this stuff, so you may find more info there. I’m waiting on a few key pieces for my screen cast setup that I want before I start pushing things out, but they’ll be coming pretty soon – within the next few weeks.

DotNetKicks Image

I’ve never met Miguel de Icaza, but I found this interview and it is quite possibly the most intelligent interview I have listened to in the last few years. He’s an extremely “balanced” individual, fair and accurate. I like that. No, I don’t like it, let me re-phrase: It’s important to me. :) If you are looking into Mono and want to get a feel for the guy behind it, then this is the interview you should listen to.

Wow.

Note: Pay attention to the part about the Mono compiler being a service to allow dynamic C#. Now. Today.

DotNetKicks Image

In an nutshell the plan is to do 1 or 2 releases that tighten up the existing code base in 2009. We won’t do too many drastic things as there doesn’t appear to be a need based on the community feedback. There are some things here and there, but overall the feedback has been overwhelmingly positive.

What does it mean in the not-so-near term? Well, dashCommerce is going to move towards an enterprise solution. What does that mean? It means a lot of things, but mainly it means we are going big. Huge. Enormous. :) Why are we going to do that? Because my spidey sense is tingling. And I’ve been fortunate enough to see things recently that I have not seen before and the end result of that is a focus on going enterprise with dashCommerce. The enterprise edition will also have a more liberal licensing model – the kind that makes developers happy. :) More on that to come. :)

We are also going to focus on making Mono a first class, supported platform for dashCommerce. What does that mean? It means dashCommerce will be cross-platform: Windows, Linux, OS X, and BSD. Why? Well, we need a broader base and being able to run only on Windows is a limiting factor. It’s the same reason people program in Ruby, PHP, Perl, etc. – they can run anywhere. Will this piss off Microsoft? Dunno. I doubt it, since they made it possible. :) I think we will also see a huge upside from a community that is well experienced and entrenched in the open source world as we bring in developers from the Linux world. (fingers crossed)

I’d love to hear your thoughts on the direction we are taking and if you have any pointers, I’d love to hear those as well.

Oh, one last thing, I want to make the engineering of dashCommerce v.Next very transparent, so I want to do some screencasts as we move through the process. I’d like you to be a part of that. I’m looking for a broad range of talent, skill, etc. So if you think you have something to contribute, let me know and we can set something up. If you are interested in sponsoring the development of dashCommerce v.Next, please drop me a note here or send me an email or PM me in the dashCommerce forums (user id chris.cyvas).

Onward and Upward! :D

DotNetKicks Image