I know similar things have been asked and the answer usually was: don't do it.
See: Is there directive for c# language version, How to know the version of the C# using the preprocessor?
But since that is not an answer to the question, let me explain. My problem is that I'm trying to edit a Library (which is a cs project) that has to be able to be compiled with old language versions (not framework versions). The new code I added does not have to be usable by projects compiling with msbuild14.0. But the whole project still must compile on older C# versions (e.g. msbuild14.0) to not branch away for bugfixes etc.
So I want the file/class I added to be ignored by older C# compilers.
I can not change the .csproj of that library for my configuration since that would effect all solutions using that library.
Maybe there is a something like a solution wide #define
? I mean I could do this (C# preprocessor define symbol based on environment variable) but it seems very hacky.