fsprojects / FsLexYacc

Lexer and parser generators for F#
http://fsprojects.github.io/FsLexYacc/
MIT License
207 stars 69 forks source link

FsLexYacc broken under .net 5.0 runtime only #134

Closed pchalamet closed 3 years ago

pchalamet commented 3 years ago

Description

Building a project (using nuget FsLexYacc 10.0.0) targeting .net 5.0 and with only .net sdk 5.0 installed is not possible. Here is a log from a build:

  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:
    - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.0.0&arch=x64&rid=osx.10.15-x64
/Users/pierre/.nuget/packages/fslexyacc/10.0.0/build/FsLexYacc.targets(43,3): error MSB3073: The command "dotnet "/Users/pierre/.nuget/packages/fslexyacc/10.0.0/build//fslex/netcoreapp3.0/fslex.dll"  -o "Lexer.fs" --module Expr.Lexer --unicode Lexer.fsl" exited with code 150.

Looks like tools are configured to run under .net 3 only.

Repro steps

Remove previously installed .net sdk and only install .net 5.0:

dotnet --list-sdks
> 5.0.100 [/usr/local/share/dotnet/sdk]

dotnet --list-runtimes
> Microsoft.AspNetCore.App 5.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
>Microsoft.NETCore.App 5.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  1. Step A

Convert a project to net5.0 (<TargetFramework>net5.0</TargetFramework>). Build it ==> it fails.

Expected behavior

FsLex and FsYacc should still work under .net 5.0.

Actual behavior

It does not work under .net 5.0.

Known workarounds

Install runtime 3.x, but it's really ugly:

curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel 3.1 --install-dir /usr/share/dotnet

Related information

Tested on macOS, .net5.0 only, using FsLexYacc 10.0.0

sergey-tihon commented 3 years ago

Are you sure that you need 3.1 sdk, I guess that It is should be enough to have 3.1 runtime (latest LTS)

pchalamet commented 3 years ago

Yes probably. It's a copy/paste from my build... Here is the min workaround:

curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel 3.0 --runtime --install-dir /usr/share/dotnet

Looking at runtime manifest of lex and yacc, I guess whichever 3.x runtime works as a workaround.

pchalamet commented 3 years ago

I've investigated a little bit this issue. Latest version on Nuget is 10.0.0 which is compiled for .net core 3.0 - unfortunately, this can't run on .net 5.0 (looks like no runtime upgrade to latest major version unlike .net core 3.1).

It looks like source code in master is not published on Nuget, RELEASE_NOTES tells about version 10.1.0 which apparently has not been released on Nuget. Support for .netcoreapp3.1 has been added by @cartermp on commit 153fd910019abf2cc2f848d89f24869cb32664cc.

I've just tested the generated nupkg on master and everything seems to work with my app and tests (using only .net sdk 5.0 to build my apps).

@cartermp @sergey-tihon @dsyme @kkm000, is there something blocking the release of a new Nuget based on master ?

Thanks!

sergey-tihon commented 3 years ago

@pchalamet I've released v10.1.0 from latest master source code, compiled for .net core 3.1.

Please try once again, but as far as I see it does not work on win and linux properly. For some magical reason it only works on macOS - Logs are here

pchalamet commented 3 years ago

Sorry Sergey, I played yesterday with target frameworks net50 and roll forward and just mess up with my tests. It does not work as is obviously, as no upgrade policy is specified. It does work with roll forward enabled.

So, easiest path to support net50 is to enable RollForward (see PR #137) on projects.

Probably worth a new nuget then šŸ˜…

pchalamet commented 3 years ago

Everything compiles (and works fine) with 10.2.0-beta1 from Nuget and only .net5.0 ! šŸŽ‰ Thanks Sergey!

   <ItemGroup>
-    <PackageReference Include="FsLexYacc" Version="10.0.0" />
+    <PackageReference Include="FsLexYacc" Version="10.2.0-beta1" />
     <PackageReference Include="FSharp.Core" Version="5.0.0" />
   </ItemGroup>
> dotnet --list-runtimes
Microsoft.AspNetCore.App 5.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

> dotnet --list-sdks
5.0.100 [/usr/local/share/dotnet/sdk]
sergey-tihon commented 3 years ago

Thank you @pchalamet for the fix!