diff --git a/RazorEngineCore/RazorEngine.cs b/RazorEngineCore/RazorEngine.cs index 672d41b..eefa62b 100644 --- a/RazorEngineCore/RazorEngine.cs +++ b/RazorEngineCore/RazorEngine.cs @@ -107,7 +107,7 @@ protected virtual RazorEngineCompiledTemplateMeta CreateAndCompileToStream(strin .Concat(options.MetadataReferences) .ToList(), new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary) - .WithOptimizationLevel(OptimizationLevel.Release) + .WithOptimizationLevel(options.IncludeDebuggingInfo ? OptimizationLevel.Debug : OptimizationLevel.Release) .WithOverflowChecks(true));