Reputation: 33391
It is possible to exclude classes from being build into the DLL?
I like to exclude the classes from being present in the release version. Debug version can have the classes.
Upvotes: 3
Views: 1928
Reputation: 43896
You can use the C# preprocessor directives for that. In your debug version, there should be a symbol DEBUG
defined, which is not defined in your release version. So your code could look like this:
#if DEBUG
public class MyClassForDebugOnly
{
// ...
}
#endif
So this class will not be available (compiled) in a release version. But note that no code that is compiled in the release version can reference this class.
To define preprocessor symbols (like DEBUG
) you can open your project properties page (right click on the project and select "Properties..."), go to the "Build" tab and edit the "Conditional compilation symbols" (a comma separated list of symbols).
For the two symbols DEBUG
and TRACE
there are two extra checkboxes which (afaik) are checked by default for debug configurations.
Upvotes: 7
Reputation: 1390
In your Project file, insert something like this;
<CSFile Include="*.cs" Exclude="Excludedfile.cs"/>
and to do it conditionally, use something like this;
<Compile
Exclude="Excludedfile.vb"
Condition=" '$(Configuration)' == 'Release' " />
Check out This link for more information, I hope this helps, you specified that this should be excluded from the build, so I thought this was more like what you wanted as opposed to a preprocessor directive :)
Upvotes: 2
Reputation: 12703
I have not tried it, but this should work:
#if (DEBUG)
public class ReleaseOnly
{
}
#endif
Upvotes: 2