Is it possible to define a compile time constant that would say if code is compiled by C# 5 or C# 6? For example:
<DefineConstants Condition=" '$(???LanguageVersion???)' != 'v6.0' ">
NOT_RUNNING_ON_6
</DefineConstants>
Is it possible to define a compile time constant that would say if code is compiled by C# 5 or C# 6? For example:
<DefineConstants Condition=" '$(???LanguageVersion???)' != 'v6.0' ">
NOT_RUNNING_ON_6
</DefineConstants>
The constants defined in the project file are all set by MSBuild. Which doesn't know the compiler version. It also only delegates all those properties to the Csc
task. Since the compiler doesn't set constants based on the version, you simply cannot do that.
You could use a custom build process wrapper that determines the compiler version and changes the project file accordingly, though.