Fable: dotnetcore version currently fails

Created on 20 Jun 2016  路  21Comments  路  Source: fable-compiler/Fable

Description

Please provide a succinct description of your issue.

Repro steps

  1. dotnet run --code "1+1"

    Expected behavior

Compiles to js

Actual behavior

Fails with

{"type":"ERROR","message":"System.Exception: Cannot read project options: Could not load file or assembly 'Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.\n\n   at [email protected](String message)\n   at Fable.Main.getProjectOptions$cont@66(ICompiler com, FSharpChecker checker, Unit unitVar)\n   at Fable.Main.compile(ICompiler com, FSharpChecker checker, FSharpOption`1 projOpts, FSharpOption`1 fileMask)"}

Known workarounds

None

Related information

  • Operating system: osx
  • Branch: dotnetcore
  • .CoreCLR
feature

Most helpful comment

I have added a minimal repro and the actual error in FCS #619, see FCS PR #628 for a fix.

All 21 comments

Hi @ncave in Fable we are seeing a similar issue to the Suave one you fixed earlier, I applied you patch to FCS here too (PR 588). There must be some other msbuild deps still left.

@7sharp9 Getting script project options was fixed by PR #588, this is an issue in the next step, project parsing. It's a bit hard to troubleshoot without a working debugger for netcore, but here it is, a quick hack to make it work: PR #589

@ncave Yeah, I only have dotnetcore purposely to see what things have gaping holes, I'll try this out later thanks!

Thanks a lot @ncave! I'll give it a try too :+1:

Is the .net core bit available for testing?

There was a very primitive version that managed to transpile 1 + 1 馃槃 but it's very outdated now. I still need to work on this. Probably I'll start after releasing v0.5 (in one or two weeks).

See #330

Thanks to the work of @ncave I've released an experimental package: fable-compiler-netcore! :tada:

However not everything is good news, the package can only read fsx scripts at the moment and I haven't managed to make it run on OSX yet. I'm trying to explain here the process I've followed to create the package in case someone can spot what I'm doing wrong. I'm also pinging @enricosada and @matthid, just because I like to spam people :wink:

  1. Install latest NETCore SDK
  2. On same level as Fable, clone FSharp.Compiler.Service and run build All.NetCore
  3. In Fable repo, run dotnet restore on all projects within src/fable (but Fable.Client.Suave which is dormant atm)
  4. In src/fable/Fable.Client.Node run dotnet publish -f netcoreapp1.0 -c release
  5. Build Fable (FableCompilerDebug target should be enough), then delete contents of build/fable/bin and replace them with the contents of src/fable/Fable.Client.Node/bin/release/netcoreapp1.0/publish
  6. Edit build/fable/package.json with new name (fable-compiler-netcore) and command (fable-netcore)
  7. After testing this on Windows, it seems I have to copy FSharp.Core.optdata and FSharp.Core.sigdata from build/fable/bin/runtimes/any/native and put them next to FSharp.Core.dll so I do it.

Now fable-compiler-netcore version correctly compiles fsx script files on my Windows machine! However, when I download and run it on my Macbook, I get the following error:

Unable to read assembly '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/1.0.0/System.Runtime.dll'

However, that assembly does exist on my machine on the specified directory. Any ideas?

Oh this looks quite similar to https://github.com/fsharp/FSharp.Compiler.Service/issues/619
its pretty bad, so I hope this gets fixed with F#4.1.

I wanted to take a look but couldn't find the time jet...

Thanks a lot for the tip, @matthid! It looks indeed it's the same issue. I'm using latest FCS code so unfortunately it seems it's not yet fixed 馃槥 Is there anything I can do to help?

@alfonsogarciacaro I think several things would help at this time:

  • obviously you can try to fix the bug and send a PR ;)
  • you can try to reproduce with the standalone fsi or fsc (latest from master for example). After this we can report to visualfsharp (and it might be a showstopper for f#4.1). This would improve the chance to get this fixed soon.
  • a minimal repro for fcs would help as well at this point

I have added a minimal repro and the actual error in FCS #619, see FCS PR #628 for a fix.

Fantastic work, thanks! :clap: I pulled your PR, built it, published a new version of fable-compiler-netcore and now it's working on OSX :tada: Maybe @7sharp9 wants to give it a try :wink: Remember it only works with scripts atm and also you may need to add references to some extra dlls like System.Text.RegularExpressions. BTW, Fable should probably add this reference automatically, does somebody know how to detect the location of NetCore basic dlls in the system?

@alfonsogarciacaro If its working on dnc then I might give it a go, do you mean add #r System.Text.RegularExpressions to the script?

I think the adding of implicit dnc references would be done with msbuild, probably have to reverse its logic, which is fine because its open source ...

Yes. I thought you had to actually indicate the path of the dll now for netcore, but after reading your comment it seems adding #r "System.Text.RegularExpressions.dll" just works :+1:

In any case, I was opening System.Text.RegularExpressions in the bindings by default. I'll remove it where it's not needed.

Tried it with an electron app and it worked as expected. #r System.Text.RegularExpressions.dll also worked fine. With the exception of having support for only fsx files, are there any known limitations?

TBH, I haven't thoroughly tested it yet ;) For now, it seems plugins are not compatible yet. I just tried and got the following error:

ERROR: Cannot load plugin node_modules/fable-plugins-nunit/Fable.Plugins.NUnit.dll: Could not load the specified file.

The exception seems to be thrown in this line. I've tried a couple of things (like compiling the plugin with .NetCore SDK or changing the line to Assembly.Load(assemblyName)) to no avail. @ncave, any ideas?

@alfonsogarciacaro See #360.

The fix is working, thanks a lot @ncave! :clap: What's more, now (most of) the tests are passing! I still need to create a FAKE target to automate everything, but with latest master, after performing the steps above 鈽濓笍 you can run the following commands to compile the tests:

node build/fable/ --verbose src/tests --projFile src/tests/files.fsx --symbols MOCHA DOTNETCORE
node build/tests/node_modules/mocha/bin/mocha build/tests/

I've published [email protected] with the latest fixes :+1:

Albeit with the limitation of fsproj files, the netcore version is working now so it's time to close this issue 馃拑

I just added a FableCompilerNetcore build target in case someone wants to build it by themselves. Please note for that you'll need to clone FCS (with @ncave's PR #628 to make it work outside Windows) on same level and build All.NetCore target in advance.

Again, thanks a lot @ncave and everybody for the splendid work 馃憦

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MangelMaxime picture MangelMaxime  路  3Comments

et1975 picture et1975  路  3Comments

nozzlegear picture nozzlegear  路  3Comments

stkb picture stkb  路  3Comments

tomcl picture tomcl  路  4Comments