简体   繁体   中英

Visual Studio 2017 Command Line build slower than IDE

When I run Visual Studio 2017 from the command line (cmd), the build is almost 3 times slower than building in the IDE.

Command line:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.com My_Project.sln /Project My_Solution /Rebuild Release  

I'm setting up a Continuous Integration system (GitLab) and I want the compiler to run before a developer Pushes the commits. A slow command line build will deter developers from using the CI system.

I'm looking for techniques for speeding up the command line build process, preferably to be faster or equal to the speed when building from the IDE.

Environment:

  • Processor: Intel(R) Xeon(R) W-2102 CPU @ 2.90Ghz 2.90 Ghz
  • Installed memory (RAM): 32.0 GB (31.7 GB usable)
  • System Type: 64-bit Operating System (Windows 7)
  • Visual Studio Professional 2017, version 15.9.16
  • NUMBER_OF_PROCESSORS=4
  • Hard drive, 581 GB free.
  • Project is using C++ and MFC for GUI.

/Rebuild This switch performs the same function as the Rebuild Solution menu command within the integrated development environment (IDE)-will clean and then build the solution from scratch, ignoring anything it's done before.

When you build projects in IDE with build option ranther than Rebuild, it will perform an incremental build: if it doesn't think it needs to rebuild a project, it won't. It may also use partially-built bits of the project if they haven't changed. That is the reason for a lot of projects build in command line but are not built in the IDE.

To make the build faster, you can change the property to /t:build in command line or select rebuild option when you build in IDE.

Besides, there are many factors that affect the speed of building, for example, parallel. When we build multiple projects in IDE, the default value of parallel is 8, Tools->options->Projects and Solutions->Build and Run:

在此处输入图片说明

So when you compare the build speed between the command line and the IDE, you have to make sure that all the relevant settings are the same for command line and IDE.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM