I am using dotnet core 2+, but the question is likely much more generic.
My CI pipeline currently looks like this:
dotnet build -c Release
dotnet test
dotnet public -c Release --no-build
For the test step, it uses the default Debug
configuration, therefore it also has to build the app using Debug
config.
Therefore, I was wondering, whether there is any advantage in running tests using Debug
rather than Release
or should i just simply add dotnet test -c Release
?
Lots of your code could be completely removed or rewritten in Release mode. The resulting executable will most likely not match up with your written code. Because of this release mode will run faster than debug mode due to the optimizations.
Debug Mode: When we are developing the application. Release Mode: When we are going to production mode or deploying the application to the server. Debug Mode: The debug mode code is not optimized. Release Mode: The release mode code is optimized.
A Debug configuration supports the debugging of an app, and a Release configuration builds a version of the app that can be deployed.
I believe it's possible to choose by comparing of the differences between "Debug" and "Release".
In Release mode: there are compiler's optimizations. Compiler does some low-level improvements. This leads to original code can be changed significantly in some places. (some variables and methods calls can be optimized in a non obvious way).
In Debug mode: code is not optimized, and along with final assemblies compiler produces .pdb files with are used for a step by step debugging.
As a conclusion, for tests, is better to use Release mode:
P.S. Along with that keep an eye on preprocessor directives and config transformation if they are presented, and depend on build configuration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With