FSharpLint icon indicating copy to clipboard operation
FSharpLint copied to clipboard

Execution fails when using dotnet 7.x or 8.x to target net6.0 project

Open plainionist opened this issue 2 years ago • 24 comments

I installed F# lint as dotnet tool as described in the documentation (version 0.24.0) and then tried to run it for a single fsproj on the command line like this:

dotnet fsharplint lint TheProject.fsproj

and i got:

Lint failed while analysing system\Bake\Bake\Bake.fsproj. Failed with: Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Stack trace: at Ionide.ProjInfo.ProjectLoader.loadProject(String path, BinaryLogGeneration binaryLogs, FSharpList1 globalProperties) at Ionide.ProjInfo.ProjectLoader.getProjectInfo(String path, FSharpList1 globalProperties, BinaryLogGeneration binaryLogs, FSharpList1 customProperties) in /_//src/Ionide.ProjInfo/Library.fs:line 641 at <StartupCode$Ionide-ProjInfo>.$Library.loadProject@906(WorkspaceLoader __, FSharpList1 customProperties, BinaryLogGeneration binaryLogs, Dictionary2 cache, String p) in /_//src/Ionide.ProjInfo/Library.fs:line 907 at <StartupCode$Ionide-ProjInfo>.$Library.loadProjectList@934(WorkspaceLoader __, FSharpList1 customProperties, BinaryLogGeneration binaryLogs, Dictionary2 cache, FSharpList1 projectList) in ///src/Ionide.ProjInfo/Library.fs:line 944 at Ionide.ProjInfo.WorkspaceLoader.Ionide.ProjInfo.IWorkspaceLoader.LoadProjects(FSharpList1 projects, FSharpList1 customProperties, BinaryLogGeneration binaryLogs) in ///src/Ionide.ProjInfo/Library.fs:line 952 at FSharpLint.Application.Lint.getProjectInfo(String projectFilePath, ToolsPath toolsPath) in /home/runner/work/FSharpLint/FSharpLint/src/FSharpLint.Core/Application/Lint.fs:line 301 at FSharpLint.Application.Lint.lintProject$cont@396(OptionalLintParameters optionalParams, String projectFilePath, ToolsPath toolsPath, Unit unitVar) in /home/runner/work/FSharpLint/FSharpLint/src/FSharpLint.Core/Application/Lint.fs:line 440 at FSharpLint.Application.Lint.lintProject(OptionalLintParameters optionalParams, String projectFilePath, ToolsPath toolsPath) in /home/runner/work/FSharpLint/FSharpLint/src/FSharpLint.Core/Application/Lint.fs:line 395 at FSharpLint.Console.Program.start(ParseResults`1 arguments, ToolsPath toolsPath) in /home/runner/work/FSharpLint/FSharpLint/src/FSharpLint.Console/Program.fs:line 133

Operating System: Window 10

dotnet --info .NET SDK: Version: 8.0.101 Commit: 6eceda187b Workload version: 8.0.100-manifests.69afb982

Runtime Environment: OS Name: Windows OS Version: 10.0.19044 OS Platform: Windows RID: win-x64 Base Path: C:\Program Files\dotnet\sdk\8.0.101\

.NET workloads installed: Workload version: 8.0.100-manifests.69afb982 There are no installed workloads to display.

Host: Version: 8.0.1 Architecture: x64 Commit: bf5e279d92

.NET SDKs installed: 5.0.301 [C:\Program Files\dotnet\sdk] 6.0.400 [C:\Program Files\dotnet\sdk] 6.0.401 [C:\Program Files\dotnet\sdk] 7.0.202 [C:\Program Files\dotnet\sdk] 8.0.101 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found: arm64 [C:\Program Files\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\arm64\InstallLocation] x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables: Not set

global.json file: Not found

Learn more: https://aka.ms/dotnet/info

Download .NET: https://aka.ms/dotnet/download

plainionist avatar Jan 21 '24 15:01 plainionist

Hi @plainionist thanks for reporting this bug!

Can you try running FSharpLint with dotnet 6.x instead of with dotnet 8.x? Just to see if it's a valid workaround.

knocte avatar Jan 22 '24 04:01 knocte

i tried

dotnet fsharplint --fx-version 6.0.9 lint system\Bake\Bake\Bake.fsproj

but got exactly same error.

Lint failed while analysing system\Bake\Bake\Bake.fsproj. Failed with: Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Stack trace: at Ionide.ProjInfo.ProjectLoader.loadProject(String path, BinaryLogGeneration binaryLogs, FSharpList1 globalProperties) at Ionide.ProjInfo.ProjectLoader.getProjectInfo(String path, FSharpList1 globalProperties, BinaryLogGeneration binaryLogs, FSharpList1 customProperties) in ///src/Ionide.ProjInfo/Library.fs:line 641 at <StartupCode$Ionide-ProjInfo>.$Library.loadProject@906(WorkspaceLoader __, FSharpList1 customProperties, BinaryLogGeneration binaryLogs, Dictionary2 cache, String p) in ///src/Ionide.ProjInfo/Library.fs:line 907`

plainionist avatar Jan 22 '24 10:01 plainionist

dotnet fsharplint --fx-version 6.0.9 lint system\Bake\Bake\Bake.fsproj

Shouldn't the fx-version flag be after dotnet and before fsharplint?

knocte avatar Jan 22 '24 12:01 knocte

@knocte that's correct - the CLI parser used by the .NET Runtime (not the SDK) is very simplistic and only accepts flags between dotnet and the command to be run.

baronfel avatar Jan 22 '24 15:01 baronfel

even though you are right according to dotnet help, it doesn't seem to work for tools

dotnet --fx-version 6.0.9 fsharplint lint system\Bake\Bake\Bake.fsproj

Could not execute because the specified command or file was not found. Possible reasons for this include:

  • You misspelled a built-in dotnet command.
  • You intended to execute a .NET program, but dotnet---fx-version does not exist.
  • You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

plainionist avatar Jan 25 '24 05:01 plainionist

Oh bummer! Then do you mind uninstalling 8.0.100 and try? This way it will run with 6.x or 7.x.

knocte avatar Jan 25 '24 06:01 knocte

After having uninstalled .NET 8 SDK, .NET 7 has been taken - unsuccessfully

dotnet fsharplint lint system\Bake\Bake\Bake.fsproj

Lint failed while analysing system\Bake\Bake\Bake.fsproj. Failed with: Could not load file or assembly 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Stack trace: at Ionide.ProjInfo.ProjectLoader.loadProject(String path, BinaryLogGeneration binaryLogs, FSharpList`1 globalProperties)

Basically same error message just different verison of System.Runtime not found

plainionist avatar Jan 28 '24 18:01 plainionist

After having uninstalled .NET 7 SDK as well, finally, FSharpLint was executed successfully 👍

plainionist avatar Jan 28 '24 18:01 plainionist

Oh, so with .NET6 it works? What version of .NET6 do you have?

knocte avatar Jan 29 '24 03:01 knocte

yes - works with .NET 6 - i have following versions installed

dotnet --info .NET SDK (reflecting any global.json): Version: 6.0.401 Commit: 0906eae6f8

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

global.json file: Not found

Host: Version: 6.0.9 Architecture: x64 Commit: 163a63591c

.NET SDKs installed: 5.0.301 [C:\Program Files\dotnet\sdk] 6.0.400 [C:\Program Files\dotnet\sdk] 6.0.401 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Download .NET: https://aka.ms/dotnet-download

Learn about .NET Runtimes and SDKs: https://aka.ms/dotnet/runtimes-sdk-info

but i would prefer being able to install .NET 8 again and still use FSharpLint 😉

plainionist avatar Jan 29 '24 06:01 plainionist

but i would prefer being able to install .NET 8 again and still use FSharpLint 😉

Of course, I never stated that this is not a bug. I was trying to see if there's a workaround so that we understand the bug better.

I might push a commit later today that might or not help with this bug; I will let you know so you can test a pre-release.

knocte avatar Jan 29 '24 06:01 knocte

I might push a commit later today that might or not help with this bug; I will let you know so you can test a pre-release.

@plainionist an update was pushed to nuget, can you test new prerelease version "0.24.1--date20240129-0357.git-d05ca87" please?

knocte avatar Jan 29 '24 16:01 knocte

dotnet tool update -g dotnet-fsharplint --prerelease Tool 'dotnet-fsharplint' was successfully updated from version '0.24.0' to version '0.24.1--date20240129-0357.git-d05ca87'.

executed with only .NET 6 installed then installed latest .NET 8 again

Host: Version: 8.0.1 Architecture: x64 Commit: bf5e279d92

.NET SDKs installed: 5.0.301 [C:\Program Files\dotnet\sdk] 6.0.400 [C:\Program Files\dotnet\sdk] 6.0.401 [C:\Program Files\dotnet\sdk] 8.0.101 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

and finally got same error again :(

dotnet fsharplint lint system\Bake\Bake\Bake.fsproj Lint failed while analysing system\Bake\Bake\Bake.fsproj. Failed with: Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Stack trace: at Ionide.ProjInfo.ProjectLoader.loadProject(String path, BinaryLogGeneration binaryLogs, FSharpList1 globalProperties) at Ionide.ProjInfo.ProjectLoader.getProjectInfo(String path, FSharpList1 globalProperties, BinaryLogGeneration binaryLogs, FSharpList1 customProperties) in /_//src/Ionide.ProjInfo/Library.fs:line 842 at <StartupCode$Ionide-ProjInfo>.$Library.loadProject@1176(WorkspaceLoader __, FSharpList1 customProperties, BinaryLogGeneration binaryLogs, Dictionary2 cache, String p) in /_//src/Ionide.ProjInfo/Library.fs:line 1177 at <StartupCode$Ionide-ProjInfo>.$Library.loadProjectList@1213(WorkspaceLoader __, FSharpList1 customProperties, BinaryLogGeneration binaryLogs, Dictionary2 cache, FSharpList1 projectList) in ///src/Ionide.ProjInfo/Library.fs:line 1233 at Ionide.ProjInfo.WorkspaceLoader.Ionide.ProjInfo.IWorkspaceLoader.LoadProjects(FSharpList1 projects, FSharpList1 customProperties, BinaryLogGeneration binaryLogs) in ///src/Ionide.ProjInfo/Library.fs:line 1241 at FSharpLint.Application.Lint.getProjectInfo(String projectFilePath, ToolsPath toolsPath) in /home/runner/work/FSharpLint/FSharpLint/src/FSharpLint.Core/Application/Lint.fs:line 302 at FSharpLint.Application.Lint.lintProject$cont@397(OptionalLintParameters optionalParams, String projectFilePath, ToolsPath toolsPath, Unit unitVar) in /home/runner/work/FSharpLint/FSharpLint/src/FSharpLint.Core/Application/Lint.fs:line 441 at FSharpLint.Application.Lint.lintProject(OptionalLintParameters optionalParams, String projectFilePath, ToolsPath toolsPath) in /home/runner/work/FSharpLint/FSharpLint/src/FSharpLint.Core/Application/Lint.fs:line 396 at FSharpLint.Console.Program.start(ParseResults`1 arguments, ToolsPath toolsPath) in /home/runner/work/FSharpLint/FSharpLint/src/FSharpLint.Console/Program.fs:line 133

plainionist avatar Jan 29 '24 19:01 plainionist

Ok I tried to reproduce this bug, using dotnet 7.x (in particular 7.0.115), and with the default fsproj generated by the command dotnet new classlib -lang "F#" -o src/Library, and I didn't get the crash.

@plainionist can you try to reproduce with the same dotnet new command above, and if that doesn't cause a crash, then I guess you would need to upload your special .fsproj file here.

knocte avatar Jan 30 '24 11:01 knocte

i can try later - meanwhile here is the content of the project i used for testing - maybe this helps (compile elements removed)

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
  	<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
    <OutputType>Exe</OutputType>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="FSharp.Collections.ParallelSeq" Version="1.2.0" />
    <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
  </ItemGroup>
  
  <ItemGroup>
    <PackageReference Update="FSharp.Core" Version="7.0.0" />
  </ItemGroup>

</Project>

plainionist avatar Jan 30 '24 12:01 plainionist

maybe this helps (compile elements removed)

With this I still can't reproduce it. Note I'm testing in Linux. But today a coworker managed to reproduce it (he doesn't repro in Linux, like me, but in Windows he does).

knocte avatar Jan 31 '24 14:01 knocte

i am testing on windows and even with "default f# classlib template" i get:

dotnet new classlib -lang "F#"
The template "Class Library" was created successfully.

Processing post-creation actions...
Restoring C:\ws\plainionist\temp\temp.fsproj:
  Determining projects to restore...
  Restored C:\ws\plainionist\temp\temp.fsproj (in 751 ms).
Restore succeeded.
dotnet fsharplint lint temp.fsproj
Lint failed while analysing temp.fsproj.
Failed with: Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Stack trace:    at Ionide.ProjInfo.ProjectLoader.loadProject(String path, BinaryLogGeneration binaryLogs, FSharpList`1 globalProperties)
   at Ionide.ProjInfo.ProjectLoader.getProjectInfo(String path, FSharpList`1 globalProperties, BinaryLogGeneration binaryLogs, FSharpList`1 customProperties) in /_//src/Ionide.ProjInfo/Library.fs:line 842
   at <StartupCode$Ionide-ProjInfo>.$Library.loadProject@1176(WorkspaceLoader __, FSharpList`1 customProperties, BinaryLogGeneration binaryLogs, Dictionary`2 cache, String p) in /_//src/Ionide.ProjInfo/Library.fs:line 1177
   at <StartupCode$Ionide-ProjInfo>.$Library.loadProjectList@1213(WorkspaceLoader __, FSharpList`1 customProperties, BinaryLogGeneration binaryLogs, Dictionary`2 cache, FSharpList`1 projectList) in /_//src/Ionide.ProjInfo/Library.fs:line 1233

plainionist avatar Feb 01 '24 06:02 plainionist

I have the same issue, but I have an .net8.0 project.

System.Runtime, Version=8.0.0.0 missing.

Hardt-Coded avatar Feb 10 '24 13:02 Hardt-Coded

We have managed to reproduce the problem in CI: https://github.com/webwarrior-ws/FSharpLint/commits/reproduce-687/

The tricky thing will be to fix it. Maybe switching to .net8.0 is our best bet, but:

  1. I would love to find the root cause, otherwise we might need to upgrade to newer .NET versions as soon as they are released.
  2. Migrating to .net8.0 might mean that people using .net6.0 cannot use the last version of FSharpLint anymore.

Help welcome :)

knocte avatar Feb 17 '24 11:02 knocte

As a test, I tried setting the roll forward behaviour for the fsharplint tool to latestMajor (the default in the fsharp-lint nuget package is Major) and that seems to have got it to run on a .NET 6.0 project that I'm building using the .NET 8.0 SDK.

Note: When I tried it with the 0.24.0 release it didn't produce any results (which sounds like #690), but using the latest preview release worked.

Numpsy avatar Feb 20 '24 13:02 Numpsy

I have the same issue

xperiandri avatar Mar 03 '24 18:03 xperiandri

@xperiandri Does it work if you do

set DOTNET_ROLL_FORWARD=latestMajor

before running fsharplint (using version 0.24.2) ?

Numpsy avatar Mar 03 '24 20:03 Numpsy

I had the same issue using .Net 8 on Linux.

Using DOTNET_ROLL_FORWARD=latestMajor worked for me.

Darkle avatar Mar 10 '24 22:03 Darkle

Workaround: If you have .NET 8 installed and you get this error, temporarily add following globals.json to the root:

{
    "sdk": {
        "version": "6.0.403",
        "rollForward": "minor"
    }
}

Then you can run FSharpLint. And after results delete the file.

Thorium avatar Mar 14 '24 19:03 Thorium