dotnet / docs

This repository contains .NET Documentation.
https://learn.microsoft.com/dotnet
Creative Commons Attribution 4.0 International
4.23k stars 5.87k forks source link

Build system not aware of preprocessor symbols representing the target frameworks #9343

Closed victor-david closed 5 years ago

victor-david commented 5 years ago

"The build system is aware of preprocessor symbols representing the target frameworks..."

This doesn't seem to be the case. I created the following sample console app in Visual Studio 2017 15.9.2 and switched the framework version to everything from 3.5 to 4.61. None of them activated their corresponding conditional block.

class Program
{
    static void Main(string[] args)
    {

if NET35

        bad code

endif

if NET40

        bad code

endif

if NET45

        bad code

endif

if NET451

        bad code

endif

if NET452

        bad code

endif

if NET46

        bad code

endif

if NET461

        bad code

endif

    }
}

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

mairaw commented 5 years ago

Thanks @victor-david for your feedback. I need to add some information to that topic and #if preprocessor directive topics that this behavior only applies to SDK-style projects (.NET Core projects).

victor-david commented 5 years ago

I thought that might be the case, but wasn't sure. Thanks for the clarification. @mairaw