Dan Tao
Dan Tao

Reputation: 128357

Compiling source code in debug mode using a CodeDomProvider

I have some source code I'd like to compile using the Microsoft.CSharp.CSharpCodeProvider class, and I want to include stuff that's specific to debug builds (e.g., methods marked with the [Condtional("DEBUG")] attribute).

I tried setting the CompilerParameters.CompilerOptions property to "/debug", but when I ran the compiled code the debug stuff didn't seem to be included; so I suspect that wasn't the correct way to accomplish what I want.

How can I do this?

Upvotes: 1

Views: 923

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1502126

You should be able to set CompilerOptions to /d:DEBUG which will define the DEBUG preprocessor symbol. That's what conditional compilation is based on, rather than the /debug flag - the latter controls whether debug information is emitted.

Upvotes: 7

Related Questions