[SPRNET-1267] Add optimize compiler flag for release build Created: 09/Nov/09  Updated: 07/Dec/09  Resolved: 07/Dec/09

Status: Resolved
Project: Spring.NET
Component/s: Spring-NET-CORE
Affects Version/s: 1.3.0 RC1
Fix Version/s: 1.3.0

Type: Improvement Priority: Minor
Reporter: Mark Pollack Assignee: Mark Pollack
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


The build scripts did not include the optimize compiler flag. This results (in at least) the IsJITOptimizerDisabled flag set to true in the current build for RELEASE mode. It should be set to false.

The correct flag settings are

RELEASE: IsJITTrackingEnabled=false and IsJITOptimizerDisabled=false
DEBUG: IsJITTrackingEnabled=true and IsJITOptimizerDisabled=true

Comment by Mark Pollack [ 09/Nov/09 ]

Fixed by adding

<property name="build.optimize" value="false"/> to <target name="set-debug-build-configuration">


<property name="build.optimize" value="true"/> to <target name="set-release-build-configuration">

NAnt Build files updated to add optimize="${build.optimize}" option to csc task

Added test cases to check for the correct flag settings in the assembly metadata.

Good background information to investvate release/debug builds are


Comment by Mark Pollack [ 09/Nov/09 ]

A useful tip, in case you want to run the existing Spring.NET dlls with optimization turned on is on this post



You can have the best of both worlds with a rather neat trick. The major differences between the default debug build and default release build are that when doing a default release build, optimization is turned on and debug symbols are not emitted. So:

Step 1: Change your release config to emit debug symbols. This has virtually no effect on the performance of your app, and is very useful if (when?) you need to debug a release build of your app.

Step 2: Compile using your new release build config, i.e. with debug symbols and with optimization. Note that 99% of code optimization is done by the JIT compiler, not the language compiler, so read on...

Step 3: Create a text file in your app's folder called xxxx.ini (or dll or whatever), where xxxx is the name of your executable. This text file should initially look like:

[.NET Framework Debugging Control]

Step 4: With these settings, your app runs at full speed. When you want to debug your app by turning on debug tracking and possibly turning off (CIL) code optimization, just use the following settings:

[.NET Framework Debugging Control]


Note that this applies to Foo.dll and/or Foo.exe, create a Foo.ini with the above information.

Generated at Fri Jul 10 06:50:19 UTC 2020 using Jira 8.5.4#805004-sha1:0444eab799707f9ad7b248d69f858774aadfd250.