Visual Studio: how to change the target structure used by the editor?

I have a multi-platform solution with many csproj files configured this way:

 <PropertyGroup> <TargetFrameworks>net452;netstandard1.4</TargetFrameworks> </PropertyGroup> <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.4' "> <PackageReference Include="System.Net.Http" Version="4.3.0"/> <PackageReference Include="Newtonsoft.Json" Version="9.0.1" /> </ItemGroup> <ItemGroup Condition=" '$(TargetFramework)' == 'net452' "> <Reference Include="System.Net" /> <Reference Include="System.Net.Http" /> <PackageReference Include="Newtonsoft.Json" Version="6.0.8" /> </ItemGroup> 

Note that I do not have a TargetFramework element (single form). I have only the TargetFrameworks element (plural form).

The editor assumes netstandard1.4 , and all #if NET452 blocks turn gray without IntelliSense.

How can I tell the Visual Studio editor to recognize a specific target structure ( net452 , netstandard1.4 ) and get IntelliSense, at least temporarily?

For reference, I am using VS2017 Professional version 15.2 (26430.16).

+5
source share
1 answer

Here's the answer:

  • Visual Studio 2017 contains 3 combined blocks above the editor. In version 15.1 or higher, the left-most combination allows you to select the structure for editing. This will change the syntax highlighting of the #if blocks according to the selected structure.
  • IntelliSense seems to cover all the elements declared in TargetFrameworks , even if the text is grayed out in the editor.

All in all, it was just my learning curve.

+2
source

Source: https://habr.com/ru/post/1270762/


All Articles