<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="https://stackoverflow.com/questions/476163">NAnt or MSBuild, which one to choose and when?</a>  </p>
</blockquote>



<p>What is the best build tool for <a href="http://en.wikipedia.org/wiki/.NET_Framework" rel="nofollow noreferrer">.NET</a>?</p>

<p>I currently use <a href="http://en.wikipedia.org/wiki/NAnt" rel="nofollow noreferrer">NAnt</a> but only because I have experience with <a href="http://en.wikipedia.org/wiki/Apache_Ant" rel="nofollow noreferrer">Ant</a>. Is <a href="http://en.wikipedia.org/wiki/MSBuild" rel="nofollow noreferrer">MSBuild</a> preferred?</p>

[{'answer_id': 16558, 'author': 'Sören Kuklau', 'author_id': 1600, 'author_profile': 'https://Stackoverflow.com/users/1600', 'pm_score': 0, 'selected': False, 'text': "<p>Generally speaking, I get the impression that NAnt offers more flexibility compared to MSBuild, whereas (with my relatively simple needs) I've been fine with the latter so far.</p>\n"}, {'answer_id': 16559, 'author': 'Greg Hurlman', 'author_id': 35, 'author_profile': 'https://Stackoverflow.com/users/35', 'pm_score': 2, 'selected': False, 'text': '<p>We use MSBuild, because we started with Visual&nbsp;Studio&nbsp;2005 (now Visual&nbsp;Studio&nbsp;2008), and MSBuild was already "built in" to the SDK - there is less maintenance on the build server. It\'s a NAnt clone, really - both tools are infinitely flexible in that they let you create custom build tasks in code, and both have a decent set of community build tasks already created.</p>\n\n<ul>\n<li><a href="http://msbuildtasks.tigris.org" rel="nofollow noreferrer">MSBuild Community Tasks</a></li>\n<li><a href="http://nantcontrib.sourceforge.net/" rel="nofollow noreferrer">NAntContrib</a></li>\n</ul>\n'}, {'answer_id': 16564, 'author': 'Peter Meyer', 'author_id': 1875, 'author_profile': 'https://Stackoverflow.com/users/1875', 'pm_score': 6, 'selected': True, 'text': '<p>We actually use a combination of <a href="http://en.wikipedia.org/wiki/NAnt" rel="noreferrer">NAnt</a> and <a href="http://en.wikipedia.org/wiki/MSBuild" rel="noreferrer">MSBuild</a> with <a href="http://en.wikipedia.org/wiki/CruiseControl" rel="noreferrer">CruiseControl</a>. NAnt is used for script flow control and calls MSBuild to compile projects. After the physical build is triggered, NAnt is used to publish the individual project build outputs to a shared location.</p>\n\n<p>I am not sure this is <i>the best</i> process. I think many of us are still looking for a great build tool. One promising thing I heard recently on .NET Rocks, <a href="http://www.dotnetrocks.com/default.aspx?showNum=362" rel="noreferrer">episode 362</a>, is <a href="http://codebetter.com/blogs/james.kovacs/archive/2008/06/27/introducing-psake.aspx" rel="noreferrer">James Kovac\'s PSake</a>, a build system he based entirely on PowerShell. It sounds really promising since what you can do with PowerShell is fairly limitless in theory.</p>\n'}, {'answer_id': 16567, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': '<p>I\'ve used both and prefer <a href="http://en.wikipedia.org/wiki/NAnt" rel="nofollow noreferrer">NAnt</a>. It\'s really hard for me to say one is "better" than the other.</p>\n'}, {'answer_id': 16581, 'author': 'TheSmurf', 'author_id': 1975282, 'author_profile': 'https://Stackoverflow.com/users/1975282', 'pm_score': 1, 'selected': False, 'text': '<p>I have used both MSBuild and NAnt, and I much prefer MSBuild, mainly because it requires a lot less configuration by default. Although you can over-complicate things and load MSBuild down with a lot of configuration junk too, at its simplest, you can just point it at a solution/project file and have it go which, most of the time, for most cases, is enough.</p>\n'}, {'answer_id': 16589, 'author': 'Riri', 'author_id': 298, 'author_profile': 'https://Stackoverflow.com/users/298', 'pm_score': 1, 'selected': False, 'text': '<p>It also depends on <strong>what</strong> you\'re building. The <a href="http://www.codeplex.com/sdctasks" rel="nofollow noreferrer">MSBuild SDC Task library</a> has a couple of special tasks. For example, for <a href="http://en.wikipedia.org/wiki/Active_Directory" rel="nofollow noreferrer">AD</a>, <a href="https://en.wikipedia.org/wiki/Microsoft_BizTalk_Server" rel="nofollow noreferrer">BizTalk</a>, etc.</p>\n\n<blockquote>\n  <p>There are over 300 tasks included in\n  this library including tasks for:\n  creating websites, creating\n  application pools, creating\n  ActiveDirectory users, running <a href="http://en.wikipedia.org/wiki/FxCop" rel="nofollow noreferrer">FxCop</a>,\n  configuring virtual servers, creating\n  zip files, configuring <a href="https://en.wikipedia.org/wiki/Component_Object_Model#COM.2B_and_DCOM" rel="nofollow noreferrer">COM+</a>, creating\n  folder shares, installing into the\n  <a href="http://en.wikipedia.org/wiki/Global_Assembly_Cache" rel="nofollow noreferrer">GAC</a>, configuring <a href="http://en.wikipedia.org/wiki/Microsoft_SQL_Server" rel="nofollow noreferrer">SQL Server</a>,\n  configuring BizTalk 2004 and BizTalk\n  2006, etc.</p>\n</blockquote>\n'}, {'answer_id': 16600, 'author': 'Jamie', 'author_id': 922, 'author_profile': 'https://Stackoverflow.com/users/922', 'pm_score': 4, 'selected': False, 'text': '<p>I\'d just like to throw <a href="https://en.wikipedia.org/wiki/FinalBuilder" rel="nofollow noreferrer">FinalBuilder</a> in to the mix. It\'s not free, but if you\'re fed up with editing <a href="http://en.wikipedia.org/wiki/XML" rel="nofollow noreferrer">XML</a> files and want a somewhat nicer (<a href="http://en.wiktionary.org/wiki/IMO" rel="nofollow noreferrer">IMO</a>) environment to work in I would give it a go.</p>\n\n<p>I\'ve worked with all of them and have always went back to FinalBuilder.</p>\n'}, {'answer_id': 17316, 'author': 'Lee', 'author_id': 1954, 'author_profile': 'https://Stackoverflow.com/users/1954', 'pm_score': 3, 'selected': False, 'text': '<p>I use MSBuild completely for building.  Here\'s my generic MSBuild script that searches the tree for .csproj files and builds them:</p>\n\n<pre><code>&lt;Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build"&gt;\n  &lt;UsingTask AssemblyFile="$(MSBuildProjectDirectory)\\bin\\xUnit\\xunitext.runner.msbuild.dll" TaskName="XunitExt.Runner.MSBuild.xunit"/&gt;\n  &lt;PropertyGroup&gt;\n    &lt;Configuration Condition="\'$(Configuration)\'==\'\'"&gt;Debug&lt;/Configuration&gt;\n    &lt;DeployDir&gt;$(MSBuildProjectDirectory)\\Build\\$(Configuration)&lt;/DeployDir&gt;\n    &lt;ProjectMask&gt;$(MSBuildProjectDirectory)\\**\\*.csproj&lt;/ProjectMask&gt;\n    &lt;ProjectExcludeMask&gt;&lt;/ProjectExcludeMask&gt;\n    &lt;TestAssembliesIncludeMask&gt;$(DeployDir)\\*.Test.dll&lt;/TestAssembliesIncludeMask&gt;\n  &lt;/PropertyGroup&gt;\n\n  &lt;ItemGroup&gt;\n    &lt;ProjectFiles Include="$(ProjectMask)" Exclude="$(ProjectExcludeMask)"/&gt;\n  &lt;/ItemGroup&gt;\n\n  &lt;Target Name="Build" DependsOnTargets="__Compile;__Deploy;__Test"/&gt;\n\n  &lt;Target Name="Clean"&gt;\n    &lt;MSBuild Projects="@(ProjectFiles)" Targets="Clean"/&gt;\n    &lt;RemoveDir Directories="$(DeployDir)"/&gt;\n  &lt;/Target&gt;\n\n  &lt;Target Name="Rebuild" DependsOnTargets="Clean;Build"/&gt;\n\n  &lt;!--\n  ===== Targets that are meant for use only by MSBuild =====\n  --&gt;\n  &lt;Target Name="__Compile"&gt;\n    &lt;MSBuild Projects="@(ProjectFiles)" Targets="Build"&gt;\n      &lt;Output TaskParameter="TargetOutputs" ItemName="AssembliesBuilt"/&gt;\n    &lt;/MSBuild&gt;\n    &lt;CreateItem Include="@(AssembliesBuilt -&gt; \'%(RootDir)%(Directory)*\')"&gt;\n      &lt;Output TaskParameter="Include" ItemName="DeployFiles"/&gt;\n    &lt;/CreateItem&gt;\n  &lt;/Target&gt;\n\n  &lt;Target Name="__Deploy"&gt;\n    &lt;MakeDir Directories="$(DeployDir)"/&gt;\n    &lt;Copy SourceFiles="@(DeployFiles)" DestinationFolder="$(DeployDir)"/&gt;\n    &lt;CreateItem Include="$(TestAssembliesIncludeMask)"&gt;\n      &lt;Output TaskParameter="Include" ItemName="TestAssemblies"/&gt;\n    &lt;/CreateItem&gt;\n  &lt;/Target&gt;\n\n  &lt;Target Name="__Test"&gt;\n    &lt;xunit Assembly="@(TestAssemblies)"/&gt;\n  &lt;/Target&gt;\n&lt;/Project&gt;\n</code></pre>\n\n<p>(Sorry if it\'s a little dense.  Markdown seems to be stripping out the blank lines.)</p>\n\n<p>It\'s pretty simple though once you understand the concepts and all the dependencies are handled automatically.  I should note that we use Visual Studio project files, which have a lot of logic built into them, but this system allows people to build almost identically both within the Visual Studio IDE or at the command line and still gives you the flexibility of adding things to the canonical build like the xUnit testing you see in the script above.</p>\n\n<p>The one PropertyGroup is where all the configuration happens and things can be customized, like excluding certain projects from the build or adding new test assembly masks.</p>\n\n<p>The ItemGroup is where the logic happens that finds all the .csproj files in the tree.</p>\n\n<p>Then there are the targets, which most people familiar with make, nAnt or MSBuild should be able to follow.  If you call the Build target, it calls __Compile, __Deploy and __Test.  The Clean target calls MSBuild on all the project files for them to clean up their directories and then the global deployment directory is deleted.  Rebuild calls Clean and then Build.</p>\n'}, {'answer_id': 53616, 'author': 'Ray', 'author_id': 4872, 'author_profile': 'https://Stackoverflow.com/users/4872', 'pm_score': 1, 'selected': False, 'text': '<p>Using a dynamic scripting language like Python, BOO, Ruby, etc. to create and maintain build scripts might be a good alternative to an XML based one like NAnt. (They tend to be cleaner to read than XML.)</p>\n'}, {'answer_id': 53619, 'author': 'Graviton', 'author_id': 3834, 'author_profile': 'https://Stackoverflow.com/users/3834', 'pm_score': 2, 'selected': False, 'text': '<p>I use a commercial software, <a href="http://www.automatedqa.com/products/abs" rel="nofollow noreferrer">Automated Build Studio</a> for the build purpose. </p>\n'}, {'answer_id': 872934, 'author': 'ferventcoder', 'author_id': 18475, 'author_profile': 'https://Stackoverflow.com/users/18475', 'pm_score': 0, 'selected': False, 'text': '<p>UppercuT uses NAnt to build and it is the insanely easy to use Build Framework.</p>\n\n<p>Automated Builds as easy as (1) solution name, (2) source control path, (3) company name for most projects!</p>\n\n<p><a href="http://projectuppercut.org" rel="nofollow noreferrer">http://projectuppercut.org/</a></p>\n\n<p>Some good explanations here: <a href="http://ferventcoder.com/category/10094.aspx" rel="nofollow noreferrer">UppercuT</a></p>\n'}, {'answer_id': 1317705, 'author': 'netbuild', 'author_id': 161464, 'author_profile': 'https://Stackoverflow.com/users/161464', 'pm_score': 3, 'selected': False, 'text': '<p>There is another new build tool (a very intelligent wrapper) called <strong>NUBuild</strong>. It\'s lightweight, open source and extremely easy to setup and provides almost no-touch maintenance. I really like this new tool, and we have made it a standard tool for our continuous build and integration of our projects (we have about 400 projects across 75 developers). Try it out.</p>\n\n<p><a href="http://nubuild.codeplex.com/" rel="nofollow noreferrer" title="NUBuild">http://nubuild.codeplex.com/</a></p>\n\n<ul>\n<li>Easy to use command line interface</li>\n<li>Ability to target all <a href="http://en.wikipedia.org/wiki/.NET_Framework" rel="nofollow noreferrer">.NET</a> Framework\nversions, that is, 1.1, 2.0, 3.0 and 3.5</li>\n<li>Supports XML based configuration</li>\n<li>Supports both project and file\nreferences</li>\n<li>Automatically generates the “complete\nordered build list” for a given\nproject – No touch maintenance.</li>\n<li>Ability to detect and display\ncircular dependencies</li>\n<li>Perform parallel build -\nautomatically decides which of the\nprojects in the generated build list\ncan be built independently.</li>\n<li>Ability to handle proxy assemblies</li>\n<li>Provides a visual clue to the build\nprocess, for example, showing “% completed”,\n“current status”, etc.</li>\n<li>Generates detailed execution log both\nin XML and text format</li>\n<li>Easily integrated with\n<a href="http://en.wikipedia.org/wiki/CruiseControl" rel="nofollow noreferrer">CruiseControl.NET</a> continuous\nintegration system</li>\n<li>Can use custom logger like XMLLogger\nwhen targeting 2.0 + version</li>\n<li>Ability to parse error logs</li>\n<li>Ability to deploy built assemblies to\nuser specified location</li>\n<li>Ability to synchronize source code\nwith source-control system</li>\n<li>Version management capability</li>\n</ul>\n'}, {'answer_id': 4981118, 'author': 'Tim Macfarlane', 'author_id': 416032, 'author_profile': 'https://Stackoverflow.com/users/416032', 'pm_score': 2, 'selected': False, 'text': '<p>We\'re using <a href="https://github.com/refractalize/bounce" rel="nofollow">Bounce</a>, a framework for cleaner build scripts in C#.</p>\n'}, {'answer_id': 5075337, 'author': 'liammclennan', 'author_id': 2785, 'author_profile': 'https://Stackoverflow.com/users/2785', 'pm_score': 2, 'selected': False, 'text': '<p><a href="http://en.wikipedia.org/wiki/Rake_%28software%29" rel="nofollow">Rake</a> and Albacore is an excellent combination. The power of Ruby and no XML.</p>\n\n<p><a href="http://tekpub.com/blogs/tekpub-free-bin/7964799-net-open-source-5-net-automation-with-rake-and-albacore-by-liam-mclennan" rel="nofollow">.NET Open Source 5 - .NET Automation with Rake and Albacore by Liam McLennan</a> [Tekpub.com]</p>\n'}]
['https://Stackoverflow.com/questions/16550', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1464/']