0

I have a question Based on This question

Is it possible in C# to define a preprocessor directive at the solution level rather than the project level.

Motivation: I have a common library, and there are two solutions that need it. I want the preprocessor directive to be present in one, and not the other, but since the library is at the project level, if I define the preprocessor directive at the project level, this obviously won't work.

JosephDoggie
  • 1,514
  • 4
  • 27
  • 57

1 Answers1

1

You can do this with a Directory.Build.props file, and put it at the root of your solution. Inside the file you can specify DefineConstants option:

<Project>
  <PropertyGroup>
    <DefineConstants>MY_DIRECTIVE</DefineConstants>
  </PropertyGroup>
</Project>
DavidG
  • 113,891
  • 12
  • 217
  • 223