Should I switch from nant to msbuild?
Asked Answered
C

18

28

I currently use nant, ccnet (cruise control), svn, mbunit. I use msbuild to do my sln build just because it was simpler to shell out.

Are there any merits to switching my whole build script to MSBuild? I need to be able to run tests, watir style tests, xcopy deploy. Is this easier?

Update: Any compelling features that would cause me to shift from nant to msbuild?

Cosset answered 14/8, 2008 at 3:36 Comment(2)
#476663Tamboura
webwesen has discovered a recursive hole in this universe, siting a reference to a question that hadn't existed, shouldn't it be the other way?Cosset
F
31

I like MSBuild. One reason is that .csproj files are msbuild files, and building in VS is just like building at the command line. Another reason is the good support from TeamCity which is the CI server I've been using. If you start using MSBuild, and you want to do more custom things in your build process, get the MSBuild Community Tasks. They give you a bunch of nice extra tasks. I haven't used NAnt for several years now, and I haven't regretted it.

Also, as Ruben mentions, there are the SDC Tasks tasks on CodePlex.

For even more fun, there is the MSBuild Extension Pack on CodePlex, which includes a twitter task.

Fronton answered 14/8, 2008 at 6:14 Comment(1)
Also there are the SDC tasks. And the Hashimi book.Alain
O
27

My advice is just the opposite - Avoid MSBuild like the plague. NANT is far far easier to set up your build to do automatic testing, deploy to multiple production environments, integrate with cruisecontrol for an entry environment, integrate with source control. We've gone through so much pain with TFS/MSBuild (Using TFSDeployer, custom powershell scripts, etc) to get it to do what we were able to do with NANT out of the box. Don't waste your time.

Ob answered 15/8, 2008 at 14:49 Comment(4)
+1 MSBuild has it's place, but NAnt is much more powerful. I've found no compelling reason to switch especially when an <msbuild> task exists in NAntContrib.Carioca
I've used both extensively, whilst I disklike the way Microsoft basically copied NAnt, MSBuild is easier to develop custom tasks for, and if you combine MSBuild Community Tasks with MSBuild Extension Pack then you have a vast array of tools. MSBuild wins because it's integrated into MS projects.Mariano
Si, you are wrong. 1) CustomTasks in NANT as simple as it gets - a subclass of Task 2) NANT has NANTContrib as well as a lot more community support than MSBuild 3) I integrate NANT into my MS projects writing a batch file to run NANT.exe. This is a build, not rocket surgery.Ob
MSBuild is different, but its just as easy and powerful to use as Nant, especially with the extension pack. Its also useful to know the tool powering your csproj file to begin with.. and you can dive in an change how builds operate for all developers (by changing the csproj) and having it happen on each build. Its also one less thing to install, and nant seems pretty dead at this point.Rugger
H
12

The most compelling reason to use MSBuild (at least in .NET 3.5 and beyond) - the build engine can build concurrently.

This means a huge speed up in your builds in you have multiple cores/processors.

Previous to 3.5, MSBuild didnt do parallel builds.

Henry answered 15/8, 2008 at 14:39 Comment(0)
G
9

I feel that MSBuild and Nant are fairly comparable. If you are using one of these, I generally wouldn't switch between them unless there was a compelling feature that was missing in the product you had selected.

I personally use MSBuild for any new project, but your mileage may vary.

Hope that helps!

Edit: @ChanChan - @Jon mentions that Nant doesn't build .NET 3.5 applications. This may be enough of a reason to either change, or at least use them in parallel. As I've moved more towards MSBuild, I am probably not the most informed person to highlight any other showstoppers with either technology.

Edit: It appears Nant now builds .NET 3.5 Applications.

Getraer answered 14/8, 2008 at 3:43 Comment(1)
NANT does build .net 3.5 applications now.Vins
S
3

NAnt has been around longer, and is a considerably more mature product, and also IMO easier to use. There is a lot of community know-how out there to tap into, and it is also cross-platform, should you be interested in building apps that can run under Mono as well as .NET and Silverlight. Out of the box, it does a whole lot more than MSBuild does. Oh yes, and you can call MSBuild from NAnt (OK, from NAntContrib) :-)

On the negative side, NAnt and its sister project NAntContrib do seem to have stagnated, with the most recent update being late 2007.

The main advantages that I see of MSBuild is that it ships with the .NET Framework, so it's one less product to install; and there is more active development going on (albeit in places to catch up with the older NAnt).

Personally, I find its syntax a little more difficult to pick up, but then I'm sure continued exposure to ti would make things easier.

Conclusion? If you're working with existing NAnt scripts, stick with them, it's not worth the hassle of porting. If you're starting a new project, and you're feeling adventurous, then give MSBuild a go.

Socle answered 17/2, 2009 at 4:20 Comment(0)
R
2

We also switched from nant to msbuild. If Your build is pretty standard, then You won't have much problems setting it up, but if You have a lot of specific build tasks, You will have to write custom ms build tasks, as there are way less custom tasks for msbuild.

If you want to display reasonable build results, You will have to mess with custom loggers etc. The whole team build is not as ripe as nant is.

But the real benefit is integration with TFS source control and reporting services. If You are not using TFS as Your source control system, it's not worth it.

Rabblement answered 4/12, 2008 at 7:37 Comment(0)
N
2
  • Don't switch unless you have a very convincing reason (at least).
  • NAnt is open source and if it weren't I wouldn't be able to customize our build system, MSBuild is not.
  • NAnt can easily run MSBuild, I'm not sure about the other way around.
  • MSBuild scripts are already written for you if you use VS2005 or newer (the project files are MSBuild files.)
  • If you use NAnt, and you use VS to edit project files, settings and configurations, you'll have to write a converter/sync tool to update your NAnt files from the VS Project files.
Nina answered 11/4, 2009 at 11:20 Comment(0)
C
1

@Brad Leach

I generally wouldn't switch between them unless there was a compelling feature that was missing

what are the compelling reasons to use msbuild? are there cons?

So far I'm getting a pretty good, "no don't bother" from your answer.

Cosset answered 14/8, 2008 at 3:49 Comment(0)
M
1

I think they're relatively comparable both in features and ease of use. Just from being C# based I find msbuild easier to work with than nants, though that's hardly a compelling reason to switch.

What exactly is nant not doing for you? Or are you just hoping there's some cool feature you may be missing out on? :)

One super-nice thing about C# is that if you have the .net framework, you have everything you need to run msbuild. This is fantastic when you are working on large teams / projects and have people/hardware turnover.

Personally I prefer SCons over both of them :)

Marola answered 14/8, 2008 at 6:7 Comment(0)
L
1

The main reason I still use nAnt over msbuild for my automated builds is that I have more granular control on my builds. Due to msbuild using the csproj has it's build file, all the source in that project is compiled into one assembly. Which causes me to have a lot of projects in my solution for large projects where I am separating logic. Well with nant, I can arrange my build where I can compile what I want into multiple assemblies from one project.

I like this route, because it keeps me from having to many project files in my solution. I can have one project with folders splitting out the layers and then use nant to build each layer into it's own assembly.

However, I do use both nant and msbuild in conjunction for some build tasks, like building WPF applications. It is just a lot easier to compile a WPF application with the msbuild target within nant.

To end this and the point of my answer is that I like to use them side by side, but when I use msbuild in this configuration, it is usually for straight compiling, not performing any build automation tasks like copying files to a directory, generating the help documentation, or running my unit tests for example.

Layard answered 15/8, 2008 at 14:51 Comment(2)
you can set up msbuild to produce separate assemblies in the same project. By default that is not what VS2008 does, but it isn't hard to do.Webber
these things are easily doable with msbuild.Taka
R
1

I'm actually still trying to figure this question out myself, but there is one big bonus for MSBuild here: using the same build file for local continuous integration by calling msbuild.exe directly, while also being able to use VSTS's server-side continuous integration with the same build file (albeit most likely different properties/settings).

i.e. as compared to TeamCity's support for MSBuild scripts, VSTS only supports MSBuild scripts! I've hacked around this in the past by exec'ing NAnt from MSBuild; I've seen others recommend this practice as well as the reverse, but it just seems kludgey to me, so I try not to do it if I can avoid it. So, when you're using "the full Microsoft stack" (VSTS and TFS), I'd suggest just sticking with MSBuild scripts.

Rosy answered 30/11, 2008 at 7:41 Comment(0)
S
1

Nant has more features out of the box, but MSBuild has a much better fundamental structure (item metadata rocks) which makes it much easier to build reusable MSBuild scripts.

MSBuild takes a while to understand, but once you do it's very nice.

Learning materials:

Sedative answered 28/3, 2009 at 23:58 Comment(2)
the most compelling argument I've heard for msbuild is clickonce. However, I find clickonce fundamentally problematic so I avoid it, and use that as a good argument against msbuild.Cosset
Why would ClickOnce being problomatic (not that I agree with that) have any bearning on MSBuild?Obaza
V
1

I don't see any reason to switch. MsBuild itself locks you into the framework you are using. If you use NAnt, you can use it across many frameworks and shell out to msbuild to actually do the building task for you.

I am a fan of NAnt in this respect, because it decouples you from the framework a little bit.

I have created a framework that puts conventions into automated builds and I built it on NAnt. It's called UppercuT and it is the insanely easy to use Build Framework.

Automated Builds as easy as (1) solution name, (2) source control path, (3) company name for most projects!

http://code.google.com/p/uppercut/

Some good explanations here: UppercuT

Vivavivace answered 16/5, 2009 at 19:4 Comment(0)
Q
1

MSBuild being integrated with Visual Studio gives programmers less friction to use the build system. It mainly comes down to them only having to go "Build Solution" and it all works, versus having to use Custom Build Steps and other such things, or, worse, forcing developers to build by launching some kind of external script.

Now, I mostly tend to prefer MSBuild over NAnt because it's simpler. Sure, NAnt has a lot more features, is more powerful, etc., but it can quickly get out of hand. If you and your build engineers have the discipline to keep the NAnt scripts simple, then it's all good. However, I've seen too many NAnt-based systems go south to a point where nobody understands what it's doing anymore, and there's no real way to debug it besides doing the equivalent of a good ol' printf. The moment you start using some if/else statement or for loop, that's where, IMHO, it starts smelling.

On the other hand, MSBuild has a solid foundation based on metadata and a less verbose syntax. Its simplicity (or lack of features... depending on how you see it) forces you to write logic in .NET code via new tasks, instead of writing logic in XML markup. This encourages re-usability and, above all things, lets you actually debug your build system in a real debugger.

The only problem with MSBuild is the not-so-occasional bug (especially in the first version) or obscure (although documented) behaviour. And, if that's the kind of thing that really bothers you, being tied to Microsoft.

Quito answered 16/10, 2009 at 17:36 Comment(0)
P
1

I switched from NANT to MSBuild. The project is running in .Net 4.0.

My experience in Nant was good. The project kind of died. And when .Net 4.0 came along, it was time to re evaluate the build process.

Since Nant was last released MSBuild has come along ways. At this point, MSBuild is the way to go. It's easy to use, has many extensions. I rewrote my Nant scripts in a day and a half. The MSBuild script is 1/3 the size of the Nant scripts.

Much of the work in the Nant script was setting up the different environments. In MsBuild/.Net 4.0 it's built-in.

Pershing answered 11/6, 2010 at 14:52 Comment(0)
B
0

I use MSBuild alongside Nant, because the current version of Nant can't as yet compile .NET 3.5 applications (same was true when .NET 2.0 first came out).

Blastosphere answered 14/8, 2008 at 3:53 Comment(0)
C
0

The only reason I can see for using msbuild is if you would like to use a automated build server like cruise control. If you are not going to switch, then I would leave it alone.

Chlores answered 14/8, 2008 at 4:6 Comment(1)
cruisecontrol.net has tasks for nant and msbuild out of the boxLazo
J
0

I use Nant and I love it. I used MSBuild and hated it because of these:

  1. Microsoft forces you to follow their own build procedure that is so intrinsic to their doings that I at least was not able to make it work (I had to compile NET1.1 so I had to mix Nant and MSbuild). I know you can create your own MSBuild file, but I thought it was complex to understand and maintain.

  2. ItemTypes to do file operations are just too hard to follow. You can have Nant do the exact same things and much easier and direct (I had to create an ItemType list and then pass to the file operations).

  3. In MsBuild you have to create your own task dll, in Nant you can do this or you can embed C# code within your script, so its much easier to advance and just build the whole project.

  4. Nant works with Net1.1, MsBuild doesn't.

  5. To install nant, I can even unzip and locate inside my own repository to run it. To install MsBuild is much harder since it depends on many things from Visual Studio, etc. (maybe I'm wrong here, but that seems to be the truth).

Well these are my opinions...

Jones answered 30/7, 2012 at 17:21 Comment(2)
MSBuild 4.0 supports inline tasks - see msdn.microsoft.com/en-us/library/dd722601.aspx .Ineptitude
Well, but that is in VS2012. I'm talking about an VS2003 app. It's so frustrating to me that MS forces you to upgrade your whole dev stack to get new features. If they could just release each thing separately it would be much less painful.Jones

© 2022 - 2024 — McMap. All rights reserved.