<p>Does anyone have experience using makefiles for Visual Studio C++ builds (under VS 2005) as opposed to using the project/solution setup.  For us, the way that the project/solutions work is not intuitive and leads to configuruation explosion when you are trying to tweak builds with specific compile time flags.</p>

<p>Under Unix, it's pretty easy to set up a makefile that has its default options overridden by user settings (or other configuration setting).  But doing these types of things seems difficult in Visual Studio.</p>

<p>By way of example, we have a project that needs to get build for 3 different platforms.  Each platform might have several configurations (for example debug, release, and several others).  One of my goals on a newly formed project is to have a solution that can have all platform build living together, which makes building and testing code changes easier since you aren't having to open 3 different solutions just to test your code.  But visual studio will require 3 * (number of base configurations) configurations.  i.e. PC Debug, X360 Debug, PS3 Debug, etc.</p>

<p>It seems like a makefile solution is much better here.  Wrapped with some basic batchfiles or scripts, it would be easy to keep the configuration explotion to a minimum and only maintain a small set of files for all of the different builds that we have to do.</p>

<p>However, I have no experience with makefiles under visual studio and would like to know if others have experiences or issues that they can share.</p>

<p>Thanks.</p>

<p>(post edited to mention that these are C++ builds)</p>

[{'answer_id': 51872, 'author': 'aku', 'author_id': 1196, 'author_profile': 'https://Stackoverflow.com/users/1196', 'pm_score': 2, 'selected': False, 'text': '<p>Visual studio is being built on top of the <a href="http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx" rel="nofollow noreferrer">MSBuild</a> configurations files. You can consider *proj and *sln files as makefiles. They allow you to fully customize build process.</p>\n'}, {'answer_id': 51873, 'author': 'DevelopingChris', 'author_id': 1220, 'author_profile': 'https://Stackoverflow.com/users/1220', 'pm_score': 0, 'selected': False, 'text': '<p>You can use nant to build the projects individually thus replacing the solution and have 1 coding solution and no build solutions.</p>\n\n<p>1 thing to keep in mind, is that the solution and csproj files from vs 2005 and up are msbuild scripts. So if you get acquainted with msbuild you might be able to wield the existing files, to make vs easier, and to make your deployment easier.</p>\n'}, {'answer_id': 51879, 'author': 'Ben Scheirman', 'author_id': 3381, 'author_profile': 'https://Stackoverflow.com/users/3381', 'pm_score': 1, 'selected': False, 'text': '<p>While it\'s technically possible, it\'s not a very friendly solution within Visual Studio.  It will be fighting you the entire time.</p>\n\n<p>I recommend you take a look at <a href="http://nant.sf.net" rel="nofollow noreferrer">NAnt</a>.  It\'s a very robust build system where you can do basically anything you need to.</p>\n\n<p>Our NAnt script does this on every build:</p>\n\n<ol>\n<li>Migrate the database to the latest version</li>\n<li>Generate C# entities off of the database</li>\n<li>Compile every project in our "master" solution</li>\n<li>Run all unit tests</li>\n<li>Run all integration tests</li>\n</ol>\n\n<p>Additionally, our build server leverages this and adds 1 more task, which is generating Sandcastle documentation.</p>\n\n<p>If you don\'t like XML, you might also take a look at <a href="http://rake.rubyforge.org/" rel="nofollow noreferrer">Rake</a> (ruby), <a href="http://code.google.com/p/boo-build-system/" rel="nofollow noreferrer">Bake/BooBuildSystem</a> (Boo), or <a href="http://codebetter.com/blogs/james.kovacs/archive/2008/06/27/introducing-psake.aspx" rel="nofollow noreferrer">Psake</a> (PowerShell)</p>\n'}, {'answer_id': 51920, 'author': 'Nik', 'author_id': 5354, 'author_profile': 'https://Stackoverflow.com/users/5354', 'pm_score': 4, 'selected': True, 'text': "<p>I've found some benefits to makefiles with large projects, mainly related to unifying the location of the project settings.  It's somewhat easier to manage the list of source files, include paths, preprocessor defines and so on, if they're all in a makefile or other build config file.  With multiple configurations, adding an include path means you need to make sure you update every config manually through Visual Studio's fiddly project properties, which can get pretty tedious as a project grows in size.</p>\n\n<p>Projects which use a lot of custom build tools can be easier to manage too, such as if you need to compile pixel / vertex shaders, or code in other languages without native VS support.</p>\n\n<p>You'll still need to have various different project configurations however, since you'll need to differentiate the invocation of the build tool for each config (e.g. passing in different command line options to make).</p>\n\n<p>Immediate downsides that spring to mind:</p>\n\n<ul>\n<li>Slower builds: VS isn't particularly quick at invoking external tools, or even working out whether it needs to build a project in the first place.</li>\n<li>Awkward inter-project dependencies: It's fiddly to set up so that a dependee causes the base project to build, and fiddlier to make sure that they get built in the right order.  I've had some success getting SCons to do this, but it's always a challenge to get working well.</li>\n<li>Loss of some useful IDE features: Edit &amp; Continue being the main one!</li>\n</ul>\n\n<p>In short, you'll spend less time managing your project configurations, but more time coaxing Visual Studio to work properly with it.</p>\n"}, {'answer_id': 52089, 'author': 'axs6791', 'author_id': 3081, 'author_profile': 'https://Stackoverflow.com/users/3081', 'pm_score': 0, 'selected': False, 'text': '<p>We have a similar set up as the one you are describing. We support at least 3 different platforms, so the we found that using <a href="http://www.cmake.org/HTML/index.html" rel="nofollow noreferrer">CMake</a> to mange the different Visual Studio solutions. Set up can be a bit painful, but it pretty much boils down to reading the docs and a couple of tutorials. You should be able to do virtually everything you can do by going to the properties of the projects and the solution.\nNot sure if you can have all three platforms builds living together in the same solution, but you can use <a href="http://www.cmake.org/HTML/index.html" rel="nofollow noreferrer">CruiseControl</a> to take care of your builds, and running your testing scripts as often as needed.</p>\n'}]
['https://Stackoverflow.com/questions/51859', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4405/']