I'm in the middle of working on a .Net Framework (4.7.2) app, and tried to use a library that had some preprocessor symbols in it to handle .Net framework vs .net core usage.
I discovered that the built-in preprocessor symbols do not appear to be defined, in that the following works backwards:
#if NETFRAMEWORK
... some net framework code
#else
--- some .net core code (should be disabled)
#endif
If I put a "!" symbol in front of the symbol name, it reverses the enabled/disabled code, as expected, but it's still the opposite of what I should see.
I ended up having to using
#if (!NETCOREAPP && !NETSTANDARD)
.
Might this be caused by the fact that I installed VS2022?
What I have tried:
I've also tried:
0) Exiting VS and restarting
1) Deleting the .vs folder in the project
2) Loading other projects to see if it was project-specific
3) Examining the csproj file, and it correctly identifies .net 4.7.2)
4) Doing a repair on VS 2017
5) Several related built in symbols, such as
NET472
,
NET47_OR_GREATER
, and
NET20_OR_GREATER
.
6) Just to make sure the symbol evaluation was even working, I defined my own symbol
TEST_DIRECTIVE
, and it did what I expected.
7) Defined my own
NETFRAMEWORK
symbol, and that seems to be acting as expected.