Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why building project using msbuild is way slower than using visual studio IDE?

I'm trying to use the msbuild to build visual studio project using command line. I used this commands

SET VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120
msbuild.exe ../../../embedded/ports/visualC12/config-from-host.vcxproj   
/p:Configuration=Release /p:Platform=Win32  /t:rebuild

Using IDE : it took around 2 min Using cmdline: it took around 20 min

In command line it looks like it build a lot of projects that are not built in the IDE Any suggestions?

like image 385
ahmedwahdan Avatar asked Oct 15 '25 16:10

ahmedwahdan


1 Answers

In command line it looks like it build a lot of projects that are not built in the IDE Any suggestions?

That because you are using the property /t:rebuild in your command.

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. So MSBuild will build all projects regardless of whether them were built before or not.

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:

enter image description here

MSBuild command line is also support parallel, /maxcpucount Switch

msbuild.exe myproj.proj /maxcpucount:3 

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.

Hope this helps.

like image 61
Leo Liu-MSFT Avatar answered Oct 18 '25 06:10

Leo Liu-MSFT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!