<p>I run an ASP.NET website solution with a few other projects in it. I've known that MSBuild projects are capable of this, but is it the best way? Are they easy to create? Is nAnt, CruiseControl.NET or any other solution better?</p>

<p>When I build the site (using <a href="http://msdn.microsoft.com/en-us/asp.net/aa336619.aspx" rel="nofollow noreferrer">Web Deployment Projects</a>), can I automate part of the build so that it does not copy certain folders from the project into the Release folder? For instance, I have folders with local search indexes, images and other content part of the folder, but I never need or upload those when deploying the project. </p>

<p>I'm also looking toward this type of solution to automatically increment build and version numbers.</p>

[{'answer_id': 15780, 'author': 'xanadont', 'author_id': 1886, 'author_profile': 'https://Stackoverflow.com/users/1886', 'pm_score': 1, 'selected': False, 'text': "<p>CruiseControl.NET solves a different problem (continuous integration) ... however, I've had great success with NAnt for specifically what you're asking.  There's a learning curve, but once you get proficient you'll wonder how you ever got along w/o it.</p>\n"}, {'answer_id': 15810, 'author': 'Fredrik Kalseth', 'author_id': 1710, 'author_profile': 'https://Stackoverflow.com/users/1710', 'pm_score': 2, 'selected': False, 'text': '<p>You can set the Build Action/Copy to Output Directory property on individual files (select the file and hit F4 to open the properties window) to control what happens to them during build, but not for folders. This could probably be automated with a (pre) build task if you don\'t want to do it manually.</p>\n\n<p>Alternatively, you can exclude these folders from the project (right click and \'exclude from project\'); they\'ll still be there ("show all files" in solution explorer), but they won\'t be included when building the project.</p>\n'}, {'answer_id': 15892, 'author': 'Mark Cidade', 'author_id': 1659, 'author_profile': 'https://Stackoverflow.com/users/1659', 'pm_score': 1, 'selected': False, 'text': '<p>In addition to @Fredrik\'s tip about setting project items to "Copy to Output Directory", you can also specify a post-build action in the project\'s properties in the Build tab and include CMD commands like copy.exe and move.exe.</p>\n'}, {'answer_id': 16809, 'author': 'Michael Pryor', 'author_id': 245, 'author_profile': 'https://Stackoverflow.com/users/245', 'pm_score': 1, 'selected': False, 'text': '<p>We use FinalBuilder to automate a bunch of post build / pre build tasks.  There\'s also a web interface so you can kick off builds (or push websites) by logging in to the web site and clicking a button.</p>\n\n<p><a href="http://www.finalbuilder.com/" rel="nofollow noreferrer">http://www.finalbuilder.com/</a></p>\n'}, {'answer_id': 16813, 'author': 'Mark Cidade', 'author_id': 1659, 'author_profile': 'https://Stackoverflow.com/users/1659', 'pm_score': 1, 'selected': False, 'text': "<p>Can't you edit the Web Deployment project's MSBuild file for it to do what you want?</p>\n"}, {'answer_id': 32861, 'author': 'icelava', 'author_id': 2663, 'author_profile': 'https://Stackoverflow.com/users/2663', 'pm_score': 2, 'selected': False, 'text': '<p>MaseBase, you can use <a href="http://weblogs.asp.net/scottgu/archive/2005/11/06/429723.aspx" rel="nofollow noreferrer">Web Deployment Projects</a> to build and package Web Sites. We do that all the time for projects with a web application aspect. After you assign a WDP to a Web Site, you can open up the <strong>.wdproj</strong> file as plain-text XML file. At the end is a commented section of MSBuild targets that represent the sequence of events that fire during a build process.</p>\n\n<pre><code>&lt;!-- To modify your build process, add your task inside one of the targets below and uncomment it. \nOther similar extension points exist, see Microsoft.WebDeployment.targets.\n&lt;Target Name="BeforeBuild"&gt;\n&lt;/Target&gt;\n&lt;Target Name="BeforeMerge"&gt;\n&lt;/Target&gt;\n&lt;Target Name="AfterMerge"&gt;\n&lt;/Target&gt;\n&lt;Target Name="AfterBuild"&gt;\n&lt;/Target&gt;\n--&gt;\n</code></pre>\n\n<p>You can uncomment the targets you want (e.g. "AfterBuild") and insert the necessary tasks there to carry out your repeated post-build activities.</p>\n'}, {'answer_id': 157767, 'author': 'Chris', 'author_id': 40352, 'author_profile': 'https://Stackoverflow.com/users/40352', 'pm_score': 4, 'selected': True, 'text': '<p>Here\'s an example of a Web Deployment Project scripting this sort of task in the .wdproj file:</p>\n\n<pre><code>  &lt;Target Name="AfterBuild"&gt;\n    &lt;!-- ============================ Script Compression============================ --&gt;\n    &lt;MakeDir Directories="$(OutputPath)\\compressed" /&gt;\n    &lt;Exec Command="java -jar c:\\yuicompressor-2.2.5\\build\\yuicompressor-2.2.5.jar --charset UTF-8 styles.css -o compressed/styles.css" WorkingDirectory="$(OutputPath)" /&gt;\n    &lt;Exec Command="move /Y .\\compressed\\* .\\" WorkingDirectory="$(OutputPath)" /&gt;\n    &lt;RemoveDir Directories="$(OutputPath)\\sql" /&gt;\n    &lt;Exec Command="c:\\7zip-4.4.2\\7za.exe a $(ZipName).zip $(OutputPath)\\*" /&gt;\n  &lt;/Target&gt;\n</code></pre>\n\n<p>This would allow you to delete a folder.</p>\n\n<p>(I suspect that if you wanted to not have the folder copy over <em>at all</em>, the solution file would be the place to specify that, though I haven\'t had to use that.)</p>\n'}]
['https://Stackoverflow.com/questions/15774', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1888/']