vscode-csharp icon indicating copy to clipboard operation
vscode-csharp copied to clipboard

Allow choosing the Target Framework.

Open loligans opened this issue 5 years ago • 6 comments
trafficstars

Issue Description

As a user who has to target multiple Target Framework versions, I would like to be able to choose the specific framework Omnisharp should use. This functionality is homologous to this Visual Studio feature:

image

This will allow macro's like #if NETSTANDARD and #if NETFRAMEWORK to work correctly and provide intellisense in those areas.

Environment information

VSCode version: 1.44.2 C# Extension: 1.21.17

Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.1.201 Commit: b1768b4ae7

Runtime Environment: OS Name: Windows OS Version: 10.0.18363 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.1.201\

Host (useful for support): Version: 3.1.3 Commit: 4a9f85e9f8

.NET Core SDKs installed: 2.1.504 [C:\Program Files\dotnet\sdk] 2.1.508 [C:\Program Files\dotnet\sdk] 2.1.602 [C:\Program Files\dotnet\sdk] 2.1.700 [C:\Program Files\dotnet\sdk] 2.1.801 [C:\Program Files\dotnet\sdk] 2.2.202 [C:\Program Files\dotnet\sdk] 2.2.300 [C:\Program Files\dotnet\sdk] 2.2.401 [C:\Program Files\dotnet\sdk] 3.0.100-preview6-012264 [C:\Program Files\dotnet\sdk] 3.1.101 [C:\Program Files\dotnet\sdk] 3.1.201 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0-preview6.19307.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0-preview6-27804-01 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.0-preview6-27804-01 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download

Visual Studio Code Extensions
Extension Author Version
azure-account ms-vscode 0.8.9
csharp ms-dotnettools 1.21.17
debugger-for-chrome msjsdiag 4.12.6
debugger-for-edge msjsdiag 1.0.14
docomment k--kato 0.1.9
dotnet-test-explorer formulahendry 0.7.1
ecdc mitchdenny 1.3.0
EditorConfig EditorConfig 0.14.5
gitlens eamodio 10.2.1
markdown-all-in-one yzhang 2.8.0
msbuild-project-tools tintoy 0.3.5
ng-template Angular 0.901.4
partial-diff ryu1kn 1.4.1
terraform mauve 1.4.0
uridecode sryze 0.3.5
vscode-icons vscode-icons-team 10.1.1
vscode-solution-explorer fernandoescolar 0.3.9
vscode-typescript-tslint-plugin ms-vscode 1.2.3
vscode-versionlens pflannery 0.26.0
vscode-xml redhat 0.11.0
vscode-yaml redhat 0.7.2
vscodeintellicode VisualStudioExptTeam 1.2.6
vsliveshare ms-vsliveshare 1.0.2104

loligans avatar May 04 '20 20:05 loligans

Related issue: https://github.com/OmniSharp/omnisharp-vscode/issues/1783

pellared avatar Apr 07 '21 18:04 pellared

When trying to use VS Code for the development of https://github.com/open-telemetry/opentelemetry-dotnet I get a ton of errors like:

Assembly 'OpenTelemetry.Api' with identity 'OpenTelemetry.Api, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7bd6737fe5b67e3c' uses 'System.Diagnostics.DiagnosticSource, Version=5.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' which has a higher version than referenced assembly 'System.Diagnostics.DiagnosticSource' with identity 'System.Diagnostics.DiagnosticSource, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' [OpenTelemetry.Tests]

I guess that this is because the assemblies inside the System.Diagnostics.DiagnosticSource NuGet package have different versions for different targets. net45 and net46 have version 5.0.0.1 while the others (net5, netstandard1.1 and netstandard1.3) have 5.0.0.0. My understanding is that VSCode C# extension uses net452 for OpenTelemetry.Api and netcoreapp2.1 for OpenTelemetry.Tests as TargetFrameworks (because of https://github.com/OmniSharp/omnisharp-vscode/issues/1783).

Having the ability to choose a platform could help I guess. It should basically help in any project which targets multiple frameworks.

pellared avatar Apr 07 '21 20:04 pellared

  1. Is it a feature that would be good to have?
  2. Is it something where a contribution is welcome?
  3. If so, then could you give any advice on how to proceed to implement this feature.

pellared avatar Apr 08 '21 06:04 pellared

wish to support it

microestc avatar Jul 26 '21 09:07 microestc

this would be very helpful for projects which utilize code generators. In my case I'm building for net472/net5/net6 and am using protobuf to generate grpc contracts. I primarily build and work on the .net5/6 versions of the code and don't generally build the net472 flavor in my inner loop, however omnisharp insists on using the generated sources from that platform target for all intellisense checking.

Ironically, this is to support a building another code generator, which is why it's targeting net472 in the first place (msbuild.exe still runs in this version, and requires any custom build tasks to be built for it).

dnchattan avatar Aug 02 '22 03:08 dnchattan

Sorry to be an advertisement, but I am using this extension to deal with the problem. https://marketplace.visualstudio.com/items?itemName=yamachu.targetframeworksswitcher

When developing projects such as MAUI, it is difficult to develop without being able to select a target framework... So I would like to see a selection feature implemented.

yamachu avatar Aug 02 '22 04:08 yamachu

In full support of this thread. It's the 1+ VS has over Code. Can't imagine how much time I lost over the years to reorder target framework first, restart Omnisharp, and wait for the service to boot up.

Sour-Codes avatar Oct 24 '22 03:10 Sour-Codes