jeffcal's blogland

rem koolhaas couldn't build better than us!

tasks in msbuild and nant

this weekend, ted neward wrote some dispirited comments about microsoft's decision to release msbuild in light of nant's community acceptance.  now his point is larger than just the decision to release msbuild, and dare has commented on the larger issue here.  but the quandary he describes is sure to be a common one faced by many nant users.  specifically, he writes:

So if I need a custom build task to do ASP.NET deployment, do I build a NAnt task knowing its lifetime is probably scoped to this Whidbey beta cycle? Or do I build a MSBuild task knowing that it'll probably be two years before it's really useful, and that it's entirely likely that I'll have to rewrite it at least once or twice in the meantime?

i expect task authors to ask exactly these questions and frankly i think it's in the interest of both nant and msbuild to make sure we're providing solid answers.  but i thought to myself:  “there's a way to resolve this easily:  write a task that works in nant and msbuild.”  the idea isn't far fetched, as the interfaces are quite similar.  to my surprise, i found john lam already did this for an ftp task and noted the following:

[N]Ant tasks can easily port to MSBuild and vice-versa. Today I just built an FTP task that works in both MSBuild and NAnt.

to be sure, there is a bit of maintenance involved in supporting both the nant and msbuild interfaces, but in general this should work without too much effort.  have any others out there tried this?  are you interested in seeing me write a task that works in both nant and msbuild?

jeff.

Published Tuesday, May 04, 2004 11:34 AM by jeffcal
Filed under:

Comments

 

Mathew Nolton said:

i wouldn't call ted's comments dispirited. it's a true concern. microsoft can and does embrace and extend it's operating system and development tools. so i agree with ted on this one. the mere mention of Microsoft entering a space will cause people to slow down and/or stop development because no one wants to work on something when you know it will be obsolete so quickly.

per dare's comments. i see the point he is trying to make and i agree that developers ask for everything. its the nature of the beast. but it also a situation that microsoft has created. they create great tools that are integrated. but they also scare people/companies out of the market because you never know when they are going to roll over and squash any competition.
May 4, 2004 12:24 PM
 

Stephen Jones said:

How about creating an msbuild task that will run any Nant task? or visa-versa? Then there would be no issue.
May 4, 2004 1:02 PM
 

Todd Spatafore said:

Wouldn't it be a simple case of transforming the XML from one schema to another?

Besides, I don't think this is Microsoft entering the space intending to take it over, I think it's just Microsoft saying, "Hey, we have these great tools that our developers have been using for YEARS. Now we are going to let everyone use them!"

Just like Wix, and Source Safe, Microsoft is giving the community another tool to do their job. How many people out there still use CVS, how many use NSIS or InstallShield? I think the more tools we have to do our job the closer we'll come to the one that will suit us best. Innovation is great. Now if only there were more choices in the Continuous Inntegration field (anyone know of a Tinderbox replacement?)
May 4, 2004 2:26 PM
 

jeff said:

it's absolutely a true concern, and i say dispirited only in the sense that it does dampen enthusiasm about msbuild (and rightfully so until we can provide quality, well thought-out responses to these concerns). but my point isn't to respond to ted's general comments but rather specifically to the nant and msbuild situation. i think the two can live together nicely and amicably, and i wanted to highlight john's example of making this happen because i think it's a great proof of concept.

stephen's dead on with the solution that really would be the killer: a pair of tasks, one for msbuild and another for nant, which could each run tasks written for the other.
unfortunately it's not as simple as an xml translation because the task code must implement different (conflicting) interfaces depending on its target of msbuild/nant.
May 4, 2004 3:17 PM
 

Stefan Bodewig said:

I agree with Stephen that it would be fairly easy to write a NAnt task for MSBuild and vice-versa. In fact I've written NAnt and MSBuild tasks for Ant http://stefanbodewig.blogger.de/stories/101301/

Coming from a Java VM, I'm bound to use the command line. I'm sure both NAnt and MSBuild would have better options to run each other inside the same runtime instance.

One has to realize that MSBuild on the one side and (N)Ant on the other side have some different concepts underneath, though. Writing a task that works for NAnt and MSBuild at the same time is only trivial as long as the task itself is fairly trivial.

NAnt doesn't know about items at all, NAnt tasks don't have an output and they don't deal with input the way MSBuild task would do. (N)Ant tasks are supposed to be smart and perform the dependency checks themselves, while MSBuild tasks expect the MSBuild engine to do so for them.

For the same reason it wouldn't be a simple schema translation. While a MSBuild build file writer has to know the tasks input/output parameters and specify them in the build file, the (N)Ant build file writer doesn't need to do so - and most of the time won't care for the details enough to even try to.
May 10, 2004 9:11 AM
 

Artur Carvalho said:

March 23, 2005 12:37 PM
 

Artur Carvalho said:

March 23, 2005 12:37 PM
Anonymous comments are disabled

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker