Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow choosing the Target Framework. #3754

Open
loligans opened this issue May 4, 2020 · 7 comments
Open

Allow choosing the Target Framework. #3754

loligans opened this issue May 4, 2020 · 7 comments

Comments

@loligans
Copy link

loligans commented May 4, 2020

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
@pellared
Copy link

pellared commented Apr 7, 2021

Related issue: #1783

@pellared
Copy link

pellared commented Apr 7, 2021

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 #1783).

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

@pellared
Copy link

pellared commented Apr 8, 2021

  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.

@microestc
Copy link

wish to support it

tillig added a commit to tillig/opentelemetry-dotnet that referenced this issue Mar 9, 2022
PR open-telemetry#2015 fixed the target framework ordering to allow better VS Code
due to the challenges with VS Code multi-targeting:
dotnet/vscode-csharp#1783
dotnet/vscode-csharp#3754

Short version: VS Code support is better if you list the latest .NET
Core frameworks first. Recent projects and updates have lost that
ordering so VS Code isn't great on non-Windows. This restores that
order and updates the latest projects.
@dnchattan
Copy link

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).

@yamachu
Copy link

yamachu commented Aug 2, 2022

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.

@Sour-Codes
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants