It's perfectly fine to put the using directive in the #if DEBUG section, and it will remove that directive when compiling for debugging.
However, this is only part of the story; he will not complete your task on his own. Visual Studio also has a Links section in Solution Explorer. You will also need to remove the link for the assembly, or it will be included at creation.
I donβt remember anything in the Visual Studio user interface that will allow you to do this, but I expect it to be possible if you manually edit the Project file (itβs just an MSBuild file). Personally, I try very hard to avoid actions that require manual editing of project files. Visual Studio wants to own these files, and you can create conflicts in which you and Visual Studio overwrite each other.
Joel Coehoorn
source share