tintoy / msbuild-project-tools-vscode

VS Code extension for MSBuild intellisense (including PackageReference completion).
MIT License
82 stars 16 forks source link

Invalid static method syntax on .NET 5.0 RC2 #69

Closed ar0311 closed 3 years ago

ar0311 commented 3 years ago

Error: Invalid static method invocation syntax: "[MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)')". Method '[MSBuild]::GetTargetFrameworkIdentifier' not found. Static method invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(a, b)). Check that all parameters are defined, are of the correct type, and are specified in the right order.

Perhaps MSBuild needs updating again prior/in tandem to .NET 5.0 release in a few weeks.

tintoy commented 3 years ago

Hey, thanks for reporting this - I’ll take a look at it tomorrow (sorry, work’s a little crazy today!).

Will also see if we can try using the MSBuild Locator so we don’t keep running into this issue (but that may be more of a long-term goal).

tintoy commented 3 years ago

See also: tintoy/msbuild-project-tools-server#19.

tintoy commented 3 years ago

Can you try installing the extension from this package and see if it works for you?

ar0311 commented 3 years ago

Hi, no it doesn't. Same error. FYI the version of MSBuild shipping with .NET 5.0 is 16.8

tintoy commented 3 years ago

Hmm - only pre-release packages available for 16.8 at this stage. I’ll have to do some testing to see what (if anything) is broken in the new version before upgrading to it (don’t want to break behaviour for users of the current stable SDK).

ar0311 commented 3 years ago

I understand and agree that would not be ideal. It seems using MSBuild locator is the way to go going forward, so it picks up whatever the user has installed.

For instance if someone is developing against/testing a pre-release SDK then the extension will be using the same MSBuild and hopefully eliminate this type of error.

tintoy commented 3 years ago

Hmm - it looks like there are actually no packages available at all for MSBuild 16.8 yet 🙁

I'll have to keep an eye on this and wait till they publish at least pre-release packages before we can upgrade.

Sorry about that.

ViktorHofer commented 3 years ago

I'm hitting this as well and originally thought this is an Omnisharp issue, which is why I filed https://github.com/OmniSharp/omnisharp-roslyn/issues/1991.

I understand and agree that would not be ideal. It seems using MSBuild locator is the way to go going forward, so it picks up whatever the user has installed.

Fully agree. I hope that's feasible short/middle term.

tintoy commented 3 years ago

Hi - haven’t had a chance to try this out yet (work’s been a little intense the last couple of weeks) but I’m hoping to get a chance to work on it Thursday or Friday :)

ViktorHofer commented 3 years ago

Thanks a lot :)

tintoy commented 3 years ago

Ok - given how work is going this morning I won't have time to try this out until Friday but I've set aside a couple of hours tomorrow to work on it :)

tintoy commented 3 years ago

msbuild-project-tools-0.3.10.zip

Ok, the extension package linked above uses the MSBuildLocator API. I don't have the latest .NET SDK, but it does work with the SDK version I'm using (v3.1.201).

ar0311 commented 3 years ago

Looks like a winner, I have 3.1.402 and 5.0-rc2 installed here and error is gone.

Nice work!

tintoy commented 3 years ago

Thanks! Will give it some more testing over the weekend and publish a new release if it all works correctly.

ar0311 commented 3 years ago

Since 5.0 has been released I removed 3.1 SDK and installed 5.0 RTM SDK and get the following error:

Is there something in the locator that is runtime dependent?

Starting MSBuild language service... Failed to start the MSBuild language server. Error: Command failed: "/usr/local/share/dotnet/dotnet" "/Users/me/.vscode/extensions/tintoy.msbuild-project-tools-0.3.10/out/language-server/MSBuildProjectTools.LanguageServer.Host.dll" --probe It was not possible to find any compatible framework version The framework 'Microsoft.NETCore.App', version '3.0.0' was not found.

  • The following frameworks were found: 5.0.0 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.

The specified framework can be found at:

It was not possible to find any compatible framework version The framework 'Microsoft.NETCore.App', version '3.0.0' was not found.

  • The following frameworks were found: 5.0.0 at [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.

The specified framework can be found at:

tintoy commented 3 years ago

Unfortunately, an app built for the 3.x runtime won’t run on the 5.x runtime; you will also need the 3.x runtime but you can remove the 3.x SDK and just have the 5.x SDK if you want.

tintoy commented 3 years ago

See https://docs.microsoft.com/en-us/dotnet/core/versions/selection#framework-dependent-apps-roll-forward for further details.

tintoy commented 3 years ago

Published v0.3.12 of the extension (which now targets 5.0).

Sorry for the delay; had to find time to set up VMs for testing with multiple versions :)