Search code examples
visual-studiomsbuild

How to get VisualStudio build from commandline as fast as from the UI


I have a large solution (100+ projects), which can take a while to build.

However, when I am running VS UI, it can detect that it is up-to-date very quickly. I.e. if I do 2 consecutive builds with no changes, second build takes seconds.

I am working in Debug mode and when I need to build Release to run tests, I prefer to do it via commandline, so that I can do it in background. My command for running the release build is

MSBuild.exe /m:12 /v:q /p:Configuration=Release mySolution.sln -target:my_executable_project

And this command takes quite a while for every single build (including when nothing is changed).

Question: is it possible to get MSBuild check the dependencies as fast as VS (benefit somehow from the running VS)? Or is it possible to trigger a release build in VS itself from commandline?

Thanks!


Solution

  • As suggested by https://stackoverflow.com/users/4208174/jonathan-dodds, and by How to get devenv.exe to display its output on the console the command that best worked for me is:

    devenv.com my.sln /Build Release /Project my_project
    

    The build time is close to that in VS