Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to make Release and Debug both build?

I am currently using ASP.NET MVC 5 to make a web application. I always want to have a release build in my bin folder. If I set the build configuration to Release it will not debug my breakpoints. If I set it to Debug my /bin build will be a debug build.

Is there any way to generate both builds when compiling? That is, one for debugging and the second for release in the /bin folder?

like image 446
Anirudha Gupta Avatar asked May 21 '15 07:05

Anirudha Gupta


People also ask

Can you debug a Release build?

You can now debug your release build application. To find a problem, step through the code (or use Just-In-Time debugging) until you find where the failure occurs, and then determine the incorrect parameters or code.

How much faster is Release than debug?

It is well-known that Debug build in Visual C++ is very slow compared to Release build, with the typical ratio about 10-20 times. Various reasons behind it are often stated, and some people even believe that it is inevitable because it is caused by lack of compiler optimizations.

Are debug builds slower?

In general, Release builds will be faster than Debug builds. But if you're curious whether it's possible to write code that is faster in Debug, the answer is yes.


2 Answers

2019 update

In Visual Studio 2015 there actually is an option to build multiple configurations together.

You can find this option under Menu > Build > Batch Build.., this will open the following window which I think is pretty self explanatory.

Batch build screenshot VS2015

Of course if you are use to doing it with keyboard shortcuts just use: alt + B > T > Enter, and all the selected projects will build.

like image 146
Rabbi Shuki Gur Avatar answered Oct 15 '22 03:10

Rabbi Shuki Gur


There is no way to instruct VS to build more than one configuration upon build. From VS point of view the build command builds a particular project or solution of projects using a single configuration (debug and release are simply two possible configurations).

You can however use a post build command to do just about anything (including trigger the build of another configuration). However just because you can do anything post-build doesn't mean it is a best practice or even a good idea.

Before you go down that road you may want to consider if this is an xy problem. The "y" question is really "How can I have a release copy of my current codebase even if it isn't ready for release, and constantly update the last stable release with the most current codebase which happens to compile?"

Is there really a need to push production release the most recently compiled codebase (regardless of its quality) that will replace the last stable release within seconds without needing to press a single button AND while in the middle of a debug session? I would gather most experienced developers would say "no" and most team leads would say "oh hell no". It is the stuff of nightmares for project managers.

You may want to look into setting up a continual integration build server. I am taking a stab in the dark here but I am thinking it accomplishes what you need (although not what you asked).

In the past setting up a CI server had a lot of overhead for a small project so it usually didn't get done. Here is a guide on setting up CI using Visual Studio Online and Azure

like image 5
Gerald Davis Avatar answered Oct 15 '22 03:10

Gerald Davis