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

dotnet fsharplint lint ... fails to run on a machine with only .net X.0 installed, X > 5 #566

Open
SteveGilham opened this issue Aug 24, 2022 · 5 comments

Comments

@SteveGilham
Copy link
Contributor

Description

dotnet fsharplint lint ... fails to run on a machine with only .net 6.0 installed

Repro steps

  1. dotnet tool install dotnet-fsharplint
  2. Remove all .net SDKs prior to current (6.0.400 at time of writing)
  3. Invoke dotnet fsharplint lint on any .fsproj file

Expected behavior

Tool runs to analyze project

Actual behavior

Unhandled exception. System.TypeInitializationException: The type initializer for 'FSharpLint.Console.Program' threw an exception.
 ---> System.TypeInitializationException: The type initializer for '<StartupCode$dotnet-fsharplint>.$FSharpLint.Console.Program' threw an exception.
 ---> System.InvalidOperationException: No instances of MSBuild could be detected.
Try calling RegisterInstance or RegisterMSBuildPath to manually register one.
   at Microsoft.Build.Locator.MSBuildLocator.RegisterDefaults()
   at Ionide.ProjInfo.Init.init() in D:\a\proj-info\proj-info\src\Ionide.ProjInfo\Library.fs:line 17
   at <StartupCode$dotnet-fsharplint>.$FSharpLint.Console.Program..cctor() in D:\a\FSharpLint\FSharpLint\src\FSharpLint.Console\Program.fs:line 134
   --- End of inner exception stack trace ---
   at FSharpLint.Console.Program..cctor()
   --- End of inner exception stack trace ---
   at FSharpLint.Console.Program.main(String[] argv) in D:\a\FSharpLint\FSharpLint\src\FSharpLint.Console\Program.fs:line 138

Known workarounds

Install out-of-support .net 5.0.408 SDK

Related information

  • Operating system : Windows
  • Branch : nuget package dotnet-fsharplint version 0.21.2
  • .NET Runtime, CoreCLR or Mono Version : .net SDK 6.0.400
@SteveGilham
Copy link
Contributor Author

Seems to be a duplicate of #536

@SteveGilham
Copy link
Contributor Author

Probably the simplest fix would be to detect (or specify via command line) the SDK in use & feed that into a manual resolution process if the default doesn't work.

@baronfel
Copy link
Contributor

It would probably be easiest to update the proj-info dependencies, which I believe would also require updating FSharp.Compiler.Service as well. Newer proj-info dependency versions bring better resolution logic here, and better error messages.

@SteveGilham
Copy link
Contributor Author

Thinking forwards, the outcome should be resilient to a .net 7.0-only (or 8.0 only) environment without requiring a day 1 update.

@SteveGilham
Copy link
Contributor Author

SteveGilham commented Oct 22, 2023

Hit this again, on the eve of the net8.0 release, with a new dev machine that only has SDK v7.0.402 installed (from Visual Studio 17.7), and dotnet-fsharplint 0.21.3 this time.

A truly simple fix could be to have a command-line option that takes a path-to-MSBuild and registers it with RegisterMSBuildPath, if present.

FWIW, it seems that some time after version 0.53.1, Ionide.ProjInfo has been extended to read the environment for, amongst others, a DOTNET_ROOT variable for the location to search to find an MSBuild.dll, which feature could be useful to have access to.

@SteveGilham SteveGilham changed the title dotnet fsharplint lint ... fails to run on a machine with only .net 6.0 installed dotnet fsharplint lint ... fails to run on a machine with only .net X.0 installed, X > 5 Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants