#if debug --> #if myOwnConfig?

C#Visual StudioDebuggingBuildconfigurationBuildconfig

C# Problem Overview


is there a way in Visual Studio to use a custom Configuration like "#if DEBUG"

I need a "#if OFFLINE" as my Build-Config's name is "Offline" (only for further debug-purposes too)...

Thanks!

C# Solutions


Solution 1 - C#

Yes, this is possible.

Instructions:

  1. Build -> Configuration manager -> Active solution configuration -> New...
  2. Create a new configuration named: Offline.
  3. Project -> Properties -> Build -> Configuration -> Offline.
  4. Conditional compilation symbols, type: OFFLINE.
  5. Save project.
  6. Restart Visual Studio (reloading the project is not enough).

Solution 2 - C#

Yes, you can. But before you can, follow these steps:

  1. In Visual Studio, go to Properties -> Build.
  2. At the configuration dropdown, select "Offline"
  3. Add "OFFLINE" to the "Conditional compilation symbols" text box
If you skip these steps, your #if OFFLINE won't work because in that case, OFFLINE isn't defined.

Solution 3 - C#

I followed exactly the same steps as above. But they are not working. They are missing one steps or they didn't explain this clearly.

When you are doing step 4. Conditional compilation symbols: type OFFLINE. You also need to uncheck "Define DEBUG constant". Otherwise the new symbol OFFLINE won't work.

I posted this here in case someone wasted lots of time as me when try to do the same thing.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionIntegerWolfView Question on Stackoverflow
Solution 1 - C#DennisView Answer on Stackoverflow
Solution 2 - C#ProgramFOXView Answer on Stackoverflow
Solution 3 - C#user3293338View Answer on Stackoverflow