0

I would like MSBuild.exe to always use the /MP option so that projects are always built with multiple cores. I tried adding /MP to the last line of my MSBuild.rsp (in the same directory as the MSBuild.exe executable). However the /MP option is not being used. How can I get Visual Studio to always use the /MP option?

The MSBuild.rsp describes the behavior I want to use, but I haven't been able to get it to work:

The auto-response file is a special .rsp file that MSBuild.exe automatically uses when building a project. This file, MSBuild.rsp, must be in the same directory as MSBuild.exe, otherwise it will not be found. You can edit this file to specify default command line switches to MSBuild.exe. For example, if you use the same logger every time you build a project, you can add the /logger switch to MSBuild.rsp, and MSBuild.exe will use the logger every time a project is built.

I restarted my computer to verify that MSBuild.exe wasn't somehow using the prior version of MSBuild.rsp.

I verified that I was modifying the MSBuild.rsp in the same directory as MSBuild.exe by checking the "Open File Location" in Windows task manager. The project configuration MP option is blank (not explicitly disabled).

I confirmed that the /MP option in MSBuild.rsp wasn't being used by doing a "Project Only" rebuild and counting just one cl.exe instance in Windows Task Manager (if I do the same rebuild with the /MP option manually set there are more than 10 cl.exe instances).

I also tried adding a bunch of garbage to MSBuild.rsp, and no error nor warning was reported by Visual Studio, which leads me to think the MSBuild.rsp is not being used at all.

I tried enabling diagnostic output logging for MSBuild and it shows the /MP option (as an argument to Tracker.exe) when I explicitly enable it in my project's configuration settings, but if I leave the MP option blank in my project's configuration and just include it in MSBuild.rsp the /MP option is not included in this output. I don't know what Tracker.exe is (I expected to see MSBuild.exe in it's place). I also tried adding a Tracker.rsp file with /MP in the same directory as Tracker.exe on a wild guess, and that didn't help either (and I also tried adding MSBuild.rsp to my Tracker.exe directory and that also had no impact).

Just to see if the rsp file could ever work, I explicitly added the rsp file with the @ option added to my project's configuration settings, and it does show as loading in the /MP option in the diagnostic build output, but it has no effect. The /MP option is included later as an argument to cl.exe, not as an argument to Tracker.exe like it was when the MP option was specified in the project configuration. I think the option should be to MSBuild (or Tracker.exe I guess), not cl.exe.

I am using Visual Studio 2010 with mostly C++ projects.

1
  • I want to modify the default switches so that I don't have to change my project configuration directly because (1) there are dozens of projects in my solution and (2) the project configuration is version controlled and I don't want to check in these changes at this time.
    – JDiMatteo
    Jun 6, 2014 at 20:35

1 Answer 1

1

One thing you can do is to put it in a props file and have your individual projects inherit from that file. Under ItemDefinitionGroup Inside your ClCompile you'd have <MultiProcessorCompilation>true</MultiProcessorCompilation>.

2
  • Thanks Jay, that worked, and my faith in Microsoft and Visual Studio is restored! Instead of adding a props file though, I added <ClCompile> <MultiProcessorCompilation>true</MultiProcessorCompilation> </ClCompile> to the bottom of <ItemDefinitionGroup> in C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.Cpp.Default.props so that the setting would be the default for all my projects.
    – JDiMatteo
    Jun 11, 2014 at 18:34
  • Glad that helps. I'd just make sure whoever else you're working with knows to do that so you don't have divergent properties across your team. If you wanted to check it in to source control, you can make a symbolic link (via mklink) in your program files to point to your own copy of the default props file in a more convenient place (like wherever you check your projects out). Then you always have the latest copy and don't have to remember to change the file under the MSFT folder. Jun 11, 2014 at 20:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .