© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
1 reply
Ruttie

❔ CSProj DefineConstants

I have the following in my csproj:
  <PropertyGroup>
        ...
    <Configurations>Debug;Release;WIN-STEAM;MAC-STEAM;LIN-STEAM;WIN-GOG;MAC-GOG;LIN-GOG</Configurations>
  </PropertyGroup>
  <PropertyGroup>
      <DefineConstants Condition="'$(Configuration)' == 'WIN-STEAM'">$(DefineConstants);WINDOWS;STEAM</DefineConstants>
      <DefineConstants Condition="'$(Configuration)' == 'MAC-STEAM'">$(DefineConstants);MACOS;STEAM</DefineConstants>
      <DefineConstants Condition="'$(Configuration)' == 'LIN-STEAM'">$(DefineConstants);LINUX;STEAM</DefineConstants>
      <DefineConstants Condition="'$(Configuration)' == 'WIN-GOG'">$(DefineConstants);WINDOWS;GOG</DefineConstants>
      <DefineConstants Condition="'$(Configuration)' == 'MAC-GOG'">$(DefineConstants);MACOS;GOG</DefineConstants>
      <DefineConstants Condition="'$(Configuration)' == 'LIN-GOG'">$(DefineConstants);LINUX;GOG</DefineConstants>
      <DefineConstants Condition="'$(Configuration)' == 'Debug'">$(DefineConstants);WINDOWS;STEAM</DefineConstants>
  </PropertyGroup>
  <PropertyGroup>
        ...
    <Configurations>Debug;Release;WIN-STEAM;MAC-STEAM;LIN-STEAM;WIN-GOG;MAC-GOG;LIN-GOG</Configurations>
  </PropertyGroup>
  <PropertyGroup>
      <DefineConstants Condition="'$(Configuration)' == 'WIN-STEAM'">$(DefineConstants);WINDOWS;STEAM</DefineConstants>
      <DefineConstants Condition="'$(Configuration)' == 'MAC-STEAM'">$(DefineConstants);MACOS;STEAM</DefineConstants>
      <DefineConstants Condition="'$(Configuration)' == 'LIN-STEAM'">$(DefineConstants);LINUX;STEAM</DefineConstants>
      <DefineConstants Condition="'$(Configuration)' == 'WIN-GOG'">$(DefineConstants);WINDOWS;GOG</DefineConstants>
      <DefineConstants Condition="'$(Configuration)' == 'MAC-GOG'">$(DefineConstants);MACOS;GOG</DefineConstants>
      <DefineConstants Condition="'$(Configuration)' == 'LIN-GOG'">$(DefineConstants);LINUX;GOG</DefineConstants>
      <DefineConstants Condition="'$(Configuration)' == 'Debug'">$(DefineConstants);WINDOWS;STEAM</DefineConstants>
  </PropertyGroup>

However, when I add the following code:
#if MACOS && STEAM
            Console.WriteLine("Mac");
#endif
#if MACOS && STEAM
            Console.WriteLine("Mac");
#endif

And set the configuration to
MAC-STEAM
MAC-STEAM
(vs), the code does not get compiled into the project.
Any idea what I'm doing wrong?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Local csproj
C#CC# / help
11mo ago
Configure .csproj
C#CC# / help
11mo ago
.Csproj problems
C#CC# / help
2y ago
Csproj Content Include Behaviour
C#CC# / help
3mo ago