RSS Feed

Tuesday, August 19, 2008

NAnt and Setup Projects (*.vdproj)

If you're like me, you're lazy. And last night, while on my couch watching the Olympics, I attempted to do a simple thing - compile a solution containing a setup project (.vdproj) from NAnt. After all, when you're distributing a Windows Forms application to a non-technical audience, it's natural to want an installer to bootstrap to the .NET framework, copy the application to the program files directory, and create an icon on the desktop and start menu. To enhance efficiency through automation, it's also natural to want to build the software on a build server instead of manually on a developer workstation. Let's just say it took longer than a few heats of the 100m butterfly to complete this simple task. Hopefully I can decrease that learning curve for you, my fellow developer.

My first thought was, "I'll use msbuild to compile the solution". It's completely logical, but unfortunately impossible. vdproj files can only be compiled by Visual Studio. After about an hour of scouring the Internet in denial and throwing up in my bathroom, I accepted this *enormous* limitation. Apparently this issue has been known by Microsoft since at least 2004, but they haven't had time to address it. Most likely this time was instead spent pursuing the Microsoft dream. By the way, in the Microsoft dream a non-technical website administrator drags their entire SQL Server database onto the ASP.NET "design surface" and selects the publish option from the build menu.

The next problem that arises is: how do I call Visual Studio from NAnt? What executable and command-line arguments do I use? How do I dynamically determine where Visual Studio is installed? Below is some NAnt code that answers these questions:

hive="LocalMachine" />

echo message="IDE Directory is ${ide.dir}" />

commandline="src\XYZ.sln /Clean"/>

commandline="src\XYZ.sln /Rebuild Release"/>

There are a couple of ways of skinning this cat, but reading the Visual Studio 2008 path out of the registry actually turns out to be the simplest solution. I hope this helps somebody else out some day.


Neil Mosafi said...

Cor blimey! We use wix for this sort of stuff...

Anonymous said...

neil, got any links to help for bootstrapping .net with wix?

Pero said...

Look at Wix Tutorial.

Regards, Petar

Anonymous said...

Love the description of the "Microsoft dream!" Hilarious!

Anonymous said...

By the way, in the Microsoft dream a non-technical website administrator drags their entire SQL Server database onto the ASP.NET "design surface" and selects the publish option from the build menu.

And this will work… as long as said non-technical website administrator only wants to use the provided controls in exactly the way they are provided. Any deviation will require a new object developed from scratch.

Regards CJ

Ahr Family said...

the only thing that would make this blog more useful is if was added to more often than once every few months

Beulah said...

Keep up the good work.

Marcin Rybacki said...

You post saved my day, thanks! :)

mcraig88 said...

In my experience, devenv alway returns a code of 1 which causes nant to fail. Have you experienced this? I have set my <exec failonerror='false'> to get past this. Any suggestions?

patrick said...

IT's a nice blog... web application

viagra online said...

I think it is great you were capable of run this applications. It is clear that you are lazy, and so am I so I want to do exactly the same.

pharmacy said...

Also I am pretty lazy too and I hope that your tutorial can make my life way too easy.

escorts tenerife said...

In my opinion one and all should browse on this.

igitur said...

For 64bit systems, the registry key is at HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\InstallDir


Anonymous said...

buy xanax 1mg high from xanax - xanax bars difference between white yellow

Anonymous said...

xanax without prescription xanax 4h2 - xanax side effects tremors

Anonymous said...

I know this if off topic but I'm looking into starting my own blog and was wondering what all is needed to get set up? I'm assuming having a blog like yours
would cost a pretty penny? I'm not very web smart so I'm not 100% positive. Any suggestions or advice would be greatly appreciated. Kudos

Feel free to surf to my blog cash quick

Anonymous said...

Very soon this web page will be famous among all blog people,
due to it's good articles or reviews

Also visit my homepage - breast augmentation how long do they last
My web site: natural breast enlarge

Anil Gupta said...

I am very happy when read this blog post because blog post written in good manner and write on good topic. Thanks for sharing valuable information.
Digital Marketing Agencies in Bangalore, Digital Marketing Agency Bangalore

kumar said...

It is truly a great and useful piece of information. I am satisfied that you just shared this helpful info with us. Thanks a lot for posting individual information and made me more knowledgeable person.I simply want to say that absolutely very good post. Please keep update like this excellent post.
Engineering Colleges in Chennai, ECE Engineering Colleges in Chennai

Prasanth said...

A very well-written post. I read and liked the post and have also bookmarked you. All the best for future endeavors. Getting some solution regarding.
UI Designing Companies, Web Application Development in Bangalore