Fable compiled as netcoreapp2.1 is failing

Created on 1 Jun 2018  ·  18Comments  ·  Source: fable-compiler/Fable

I upgraded Fable 2 (dev2.0 branch) to netcore2.1. It was easy and it worked fine when running the tool locally as in this script. However, when distributing it as a Nuget package (version 2.0.0-alpha-008, commit reference), it fails with the following error:

~/d/f/s/r/src ❯❯❯ dotnet fable fable-splitter
Fable (2.0.0-alpha-008) daemon started on port 49195
CWD: /Users/alfonsogarciacaronunez/dev/fable/samples/react-todomvc
/Users/alfonsogarciacaronunez/dev/fable/samples/react-todomvc/node_modules/.bin/fable-splitter
fable: Compilation started at 01:23:27
CWD: /Users/alfonsogarciacaronunez/dev/fable/samples/react-todomvc/src
dotnet restore
  Restore completed in 23.93 ms for /Users/alfonsogarciacaronunez/dev/fable/samples/react-todomvc/src/React.TodoMVC.fsproj.
  Restore completed in 47.51 ms for /Users/alfonsogarciacaronunez/dev/fable/samples/react-todomvc/src/React.TodoMVC.fsproj.

Parsing ./React.TodoMVC.fsproj...
ERROR: Could not load file or assembly 'Fable.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

   at Fable.CLI.Agent.compile(Compiler com, Project project)
   at [email protected](Unit unitVar)
   at [email protected](AsyncParams`1 args)
ERROR: Could not load file or assembly 'Fable.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

Closing Fable daemon...
~/d/f/s/r/src ❯❯❯

Any ideas? @ncave @enricosada

Note the Fable.Core package still target netstandard2.0

Most helpful comment

Let me check tomorrow morning

From mobile

--
Enrico Sada
@enricosada


From: Alfonso Garcia-Caro notifications@github.com
Sent: Friday, August 31, 2018 12:15:16 AM
To: fable-compiler/Fable
Cc: Enrico Sada; Mention
Subject: Re: [fable-compiler/Fable] Fable compiled as netcoreapp2.1 is failing (#1413)

Hmm, I'm trying to follow this tutorial (basically it says you only need to add true to the .fsproj) but still no luck. Maybe @enricosadahttps://github.com/enricosada can help?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/fable-compiler/Fable/issues/1413#issuecomment-417484761, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAI_K30Fr_DrCRim9bdioo2Wzh3H5r3zks5uWGP0gaJpZM4UV4Tz.

All 18 comments

@alfonsogarciacaro idk, some version mismatch? perhaps increment the minor version? or clear packages?

I've tried several things, going back to netcoreapp2.0 was not enough, I had to revert to dotnet SDK 2.1.200. At least it's working now.

@alfonsogarciacaro I feel your pain, I can't compile FSharp.Core with netcore 2.1 too for some reason (FCS is ok though). Let me know if you want me to switch FCS-Fable back to netcore 2.0 (2.1.201 is the latest).

Yeah, it's weird. It may be some obscure assembly loading issue. I wonder why it works locally and why it fails when referenced as a package (exactly at that point). I replaced all netcoreapp2.1 to netcoreapp2.0 in all .fsproj files in the repo, so hopefully it should be fine now.

dotnet-fable 2.0.0-alpha-009 nuget pkg is working :)

@alfonsogarciacaro I guess you hit this issue. https://github.com/dotnet/sdk/issues/2171#issuecomment-389018042 . I normally switch global.json to other sdk version to make it work. Currently with 2.1.300 it is working... as per last status.

Thanks for the tip @kunjee17! Hmm, IIRC I did set global.json to 2.1.300 when check but I'll give it a new try just in case :)

@ncave I did this a new try by using dotnet SDK 2.1.401 (I changed global.json) and changing the TargetFramework to netcoreapp2.1. Then I created a .nupkg (using Release config) and installed it in another project using local sources). However when I tried to run dotnet fable in the test project I got SO exceptions during the compilation :(

@alfonsogarciacaro Bummer, why does it work locally within Fable on 2.1.401 then (tests/bench are passing), what's the difference?

No idea, I will create a branch to reproduce and open an issue in visualfsharp repo.

Damn, now I'm trying to reproduce and I can't 😬 Maybe I did something wrong before? If possible, could you please have a look at this commit and tell me if I'm doing something wrong? In theory it should allow you to use the package by following these steps:

git clean -xfd
sh build.sh Bootstrap
cd samples/react-todomvc
yarn
yarn build-pkg

This gives me No executable found matching command "dotnet-fable", but Nuget doesn't complain when running dotnet restore src (it's a postinstall script in package.json). Also, yarn build-local (which calls build/fable/dotnet-fable.dll works).

@alfonsogarciacaro Yeah, I get the same thing on Windows.
Perhaps there is something wrong with the tool package, here is what I get trying to install it:

cd Fable
dotnet tool install --global dotnet-fable --version 2.0.0-beta-100
or
dotnet tool install --global dotnet-fable --version 2.0.0-beta-100 --add-source ./build/pkg

error NU1212: Invalid project-package combination for dotnet-fable 2.0.0-beta-100.
DotnetToolReference project style can only contain references of the DotnetTool type
The tool package could not be restored.
Tool 'dotnet-fable' failed to install.

Hmm, I'm trying to follow this tutorial (basically it says you only need to add <PackAsTool>true</PackAsTool> to the .fsproj) but still no luck. Maybe @enricosada can help?

https://natemcmaster.com/blog/2018/05/12/dotnet-global-tools/

Let me check tomorrow morning

From mobile

--
Enrico Sada
@enricosada


From: Alfonso Garcia-Caro notifications@github.com
Sent: Friday, August 31, 2018 12:15:16 AM
To: fable-compiler/Fable
Cc: Enrico Sada; Mention
Subject: Re: [fable-compiler/Fable] Fable compiled as netcoreapp2.1 is failing (#1413)

Hmm, I'm trying to follow this tutorial (basically it says you only need to add true to the .fsproj) but still no luck. Maybe @enricosadahttps://github.com/enricosada can help?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/fable-compiler/Fable/issues/1413#issuecomment-417484761, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAI_K30Fr_DrCRim9bdioo2Wzh3H5r3zks5uWGP0gaJpZM4UV4Tz.

I finally managed to pack Fable as a netcore 2.1 app and install it as a global tool (dotnet tool install -g). Using the DotnetCliToolReference tag still fails. Someone at MSFT commented that they're not planning to evolve DotnetCliToolReference and only provide backwards support: https://github.com/dotnet/cli/issues/7715#issuecomment-416847787

Not sure if this means you cannot install netcore 2.1 tools as DotnetCliToolReference (which seems to be the case here). In the issue linked they also mention they're planning to enable local installation (repo-wise) of the new tools but the exact mechanism to pin versions is yet to be decided.

I guess the best thing to do is keep Fable distribution as it is now and just wait until the new local tools mechanics is announced. I didn't notice a big performance boost anyways when compiling to netcoreapp2.1 anyways.

So what happens if you install fable global tool as a local tool?
dotnet tool install fable --tool-path .\fable-compiler.
fable.exe would be installed in the fable-compiler folder in the project.
Would that solve anything?

I think that's possible @nojaf. But from what I understand from this comment from MSFT is that it's still unclear how to specify the version of the tool in the repo (as we do with Paket now). That's why I'd prefer to wait and see before making the move to local tools.

Dotnet tool install has a version flag.
dotnet tool install fantomas-tool --version 2.8.0 --tool-path .\foo
And afterwards you can check the version based on a folder in the .store.

But indeed there is no other way than to specify this manually from command line.

Fable 2.1 will fix this as we don't have restrictions on the binary target framework when putting it in an npm package.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alfonsogarciacaro picture alfonsogarciacaro  ·  3Comments

tomcl picture tomcl  ·  4Comments

jwosty picture jwosty  ·  3Comments

et1975 picture et1975  ·  3Comments

MangelMaxime picture MangelMaxime  ·  3Comments