Do MSBuild project files serve the same purpose as NMAKE makefiles in a build process? (practically equivalent)

msbuildvisual studio

I'm finding it difficult to understand Microsoft's motive behind building conceptual "projects" like this. They ship MSBuild.exe and NMAKE.exe together with a Visual Studio 2015 install but they both appear to serve the same purpose.

If they are both (in a practical sense) equivalent but using different formats, I won't bother learning how to write both. If they both have their own purposes, I might reconsider.

The following text is just my current theory on the whole thing… but I asked this question because there could be people here with experience customizing these files unlike myself…

It seems like MSBuild is made for those that depend heavily on the Visual Studio environment (.sln files) for compilation. And upon reading a little bit about it, I asked myself: Couldn't compilation of dependencies be separated by different projects allowing for partial compilation when using MSBuild? That would involve having multiple projects in a solution and then building the solution to build the entire product.

As you can see… I'm trying to understand the philosophy of MSBuild and why it's needed in the build process. At the moment, I'm starting to wonder if it's actually based on NMAKE and compiles down into NMAKE commands. That would make a whole lot of sense because I cannot see why anyone would need both in the same build process.

Best Answer

Both fulfill the same purpose of controlling and automating complex build processes. However, MSBuild is more modern, has more capabilites, and it integrates much (!) better into the build process of the Visual Studio IDE (both use actually the same "input file format" like csproj and sln files). Those project files can actually be edited and maintained (at least,to 98%) by a well structured "project properties" dialog. That is not possible easily with nmake files, because NMake was never designed for this purpose.

IMHO NMake is shipped with Visual Studio because of backwards compatibility, because of better cross platform compatibility, and because it is sometimes better suited for tasks where you have to integrate tools into your build process which are completely outside the VS IDE. The latter can be accomplished with MSBuild, too, but NMake is IMHO often a better fit if you have to create your build configuration manually - because that is what make was designed for.

NMake was Microsoft's implementation of the Unix make command, which has origins back to 1977, according to Wikipedia. Because of that history, there are still lots of projects using makefiles. Especially in the Unix/Linux world, make is still a widely used tool, and a tool like NMake provides better compatibility to the make tools used in that ecosystem.

Couldn't compilation of dependencies be separated by different projects allowing for partial compilation when using MSBuild? That would involve having multiple projects in a solution and then building the solution to build the entire product.

That is the standard approach for any bigger project, nothing really surprising. But on that abstraction level, it is not different from make/NMake.

Related Topic