Sampath
Sampath

Reputation: 65870

Disable EnableOptimizations on Debug mode

Can you tell me how to handle 'BundleConfig.cs' file's below line when we are working on debug mode ? Because I need to ignore below line on debug mode.How can I do that ? Any help would be highly appreciated.

BundleTable.EnableOptimizations = true;

Upvotes: 4

Views: 1632

Answers (1)

Mihai Dinculescu
Mihai Dinculescu

Reputation: 20033

The easiest way is to use the #if Preprocessor directive

#if DEBUG
    BundleTable.EnableOptimizations = false;
#else
    BundleTable.EnableOptimizations = true;
#endif

If your app is running in debug mode, Visual Studio defines DEBUG for you. On the other hand, if your app is running in release, DEBUG will be undefined.

In order to check if it's a release version, you check for DEBUG to not be defined

 #if !DEBUG
     BundleTable.EnableOptimizations = true;
 #endif

PS: For obvious reasons, there is no RELEASE flag.

Upvotes: 10

Related Questions