dotnet / netcorecli-fsc

[DEPRECATED] F# and .NET Core SDK working together

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Building F# fails on .NET Core 1.1 SDK

lambdakris opened this issue · comments

commented

Steps to reproduce

  1. Download and install the Current (1.1) .NET Core SDK for Windows as listed on https://www.microsoft.com/net/download/core
  2. In a new directory called fsdnc, run the following commands:
    dotnet new -lang fsharp
    dotnet restore
    dotnet build

Expected behavior

A successful build

Actual behavior

A failed build with the following output...

Project fsdnc (.NETCoreApp,Version=v1.1) will be compiled because expected outputs are missing
Compiling fsdnc for .NETCoreApp,Version=v1.1
The specified framework 'Microsoft.NETCore.App', version '1.0.0' was not found.

  • Check application dependencies and target a framework version installed at:
    C:\Program Files\dotnet\shared\Microsoft.NETCore.App
  • The following versions are installed:
    1.1.0
  • Alternatively, install the framework version '1.0.0'.
    C:\Program Files\dotnet\dotnet.exe compile-fsc @C:\Users\lambdakris\Code\fsdnc\obj\Debug\netcoreapp1.1\dotnet-compile.rsp returned Exit Code -2147450749

Compilation failed.
0 Warning(s)
0 Error(s)

Time elapsed 00:00:00.2134329

Environment info

running dotnet shows...

Microsoft .NET Core Shared Framework Host

Version : 1.1.0
Build : 928f77c4bc3f49d892459992fb6e1d5542cb5e86
...

running dotnet --version shows...

1.0.0-preview2-1-003177

running dotnet --info shows...

.NET Command Line Tools (1.0.0-preview2-1-003177)

Product Information:
Version: 1.0.0-preview2-1-003177
Commit SHA-1 hash: a2df9c2576

Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64

Workarounds

I imagine installing the LTS .NET Core SDK would work, though I have not tried this myself.

Additional Info

I also found these issues which look like the same thing:

  1. https://github.com/dotnet/cli/issues/4787
  2. dotnet/fsharp#1791

thx for bug report @lambdakris .
i can repro, i'll fix it tomorrow

commented

Hey @enricosada, thanks for looking at this. I know work is already progressing to preview3 so this is kinda like taking a step back, but I figured that since this version of the preview of the SDK is tied to a RTM release of .NET Core 1.1, even if not LTS, it is probably best to have it working just in case someone wants to use .NET Core 1.1.

If it is not too much trouble, I was wondering if as you fix, you could put the steps in the wiki? I'm thinking this could be revealing as to how .NET Core SDK integrates with F#. It could answer questions like...

  1. Where is dotnet-compile-fsc? How are dotnet/sdk, dotnet/cli, and dotnet/netcorecli-fsc related? Is the source code for dotnet-compile-fsc in here...
    https://github.com/dotnet/netcorecli-fsc/tree/master/src/dotnet-compile-fsc
    or somewhere in here...
    https://github.com/dotnet/cli
    or somewhere in here...
    https://github.com/dotnet/sdk
  2. What is dotnet-compile-fsc? I assume it calls the F# compiler (fsc.exe), but this raises a couple of sub points for me:
    1. Where is the actual F# compiler in .NET Core?
    2. How is it the actual F# compiler packaged/distributed with .NET Core?
    3. Where does the SDK make the decision to delegate to dotnet-compile-fsc?
    4. Is there more to it than just switching on the --lang fsharp option? In other words, once the SDK reaches the --lang fsharp option, does it from then on pass all control to dotnet-compile-fsc? Does the main SDK perform any work before and after dotnet-compile-fsc?
    5. How is dotnet-compile-fsc distributed with .NET Core? Can you publish this and any fix out of band or does a new SDK build need to be distributed?

I actually went through this repo and the dotnet/cli repo myself, but I'm still working out how everything is connected, so perhaps by reading the steps you took together with the PR I can piece this thing together...¯_(ツ)_/¯

@lambdakris i want to support .net 1.1 asap, just fixing preview3 because enable some early user to test it (paket/fake/suave).

Integration touch multiple repos as you see (ionide too, fsac, etc). you can start with https://github.com/dotnet/netcorecli-fsc/issues if you want small targets.

How is it the actual F# compiler packaged/distributed with .NET Core?
Is there more to it than just switching on the --lang fsharp option?

About the docs about integration, try read https://github.com/dotnet/netcorecli-fsc/blob/master/docs/fsharp_dnc_group_1.html (in a browser, not from github website). it explain at least i think the dotnet-compile-fsc.

About the wiki, i made it public, if someone want to add docs (i'll try if possibile, but is difficult).

two big:

  • dotnet new templates are embedded (as resources), so require a new sdk release to fix these. The --lang fsharp and --type console just compose the embdedd directory (FSharp_Console). it's the same for c#, but --lang c# is the default. ref wip pr dotnet/cli#4789 who add fsproj to preview4

Where is the actual F# compiler in .NET Core?
How is it the actual F# compiler packaged/distributed with .NET Core?

  • all f# stuff is on nuget packages, see dotnet-compile-fsc project.json and see deps. restoring dotnet-compile-fsc will restore f# compiler, and we run that.

How is dotnet-compile-fsc distributed with .NET Core?

I can fix dotnet-compile-fsc, publish to nuget.org vf# team (i cannot atm). Fixing that, fix the whole sdk expect dotnet new templates

Fix dotnet new templates, because embedded, require a new sdk version.
A big upgrate to dotnet-new is in the work to add remote templates ( ref #31 ) but is not done in cli. and we need f# templates

Help is really appreciated ( http://fsharp.github.io/2016/10/31/dotnetcore_sdk_group.html ) if you need info, just join #dotnetcore channel for fsharp.org slack, i can try to help if you choose to contribute an issue. or anyway if you dont want, np 😄

Hi @enricosada, @lambdakris ,
I'm curious too. Some information about versions of the components, how they work together, and how are they published to github, would be nice.
For example: there is SDK version 1.0.0-preview4-004110 on https://github.com/dotnet/cli, but this has no tools for F# compilation and no F# project templates.
However, when I download LTS version from https://www.microsoft.com/net/download/core, I can create and compile F# projects without problems.

@ondrejgr mostly is doc about sdk and .net core, for preview2, preview3, preview4 , net1.1 etc.
status of f# with these version is in wiki i hope.

To anyone: If you think there are missing points, pls modify the wiki page (or add new ones) and write questions, i'll write to answer with links/info. wiki is public

Or join #dotnetcore channel on fsharp.org slack for questions

ref https://github.com/dotnet/netcorecli-fsc/wiki/.NET-Core-SDK-preview3#notes

minimal:

  • preview2: project.json -> project.json and f# use dotnet-compile-{compilerName} extensibility of sdk.
  • preview3: already released, big change of sdk, use msbuild instaed of project.json. no templates because we where late (the project.json one where deleted because not working anymore). We can fix a lot, but not dotnet new templates because embedded. see wiki for templates.
  • preview4: it's in development now, in dotnet/cli repo. work is in progress for cli and f#. for example i sent pr to add templates dotnet/cli#4789 .

@enricosada, thanks a lot. I didn't know about the wiki, I'll check it out.

I tried building F# project targeting netcoreapp1.1 as well as 1.0 (fsproj instead of json) using sdk preview3-004059 with dotnet-compile-fsc 1.0.0-preview2-020000. Building works without any problems and I can run the applications using appropriate runtime (1.1.0/1.0.1).

I've got this same issue on a macOs Sierra 10.12.1 :/

@ondrejgr preview3 is another beast, is msbuild based so the codebase of sdk is different from preview2 train (that mean preview2.1 too)

@enricosada: since msbuild and fsproj are going to be used in future, I'm going to stick with it instead of current release (2.1).

@ondrejgr sure, i hope the next preview4 will have fixed templates ootb 😄 .
As a note, is possible to continue to use the LTS preview2 (not preview2.1 that's .NET core 1.1, and is supported only for three months, unlike LTS), that's going to continue to work (issue and workarounds are known) and be updated (next drop will be .net core 1.0.3 ). No need to rush.
But yes, using fsproj is not that bad atm, but no vs code intellisense yet 😢

I'm hitting this issue too when trying to compile a simple f# app with dotnet core 1.1 (dotnet --version says 1.0.0-preview2-1-003177) on Fedore 24 (though my exit code is 131, otherwise exactly the same message). Is there anything we can do to help to finish the PR?

PR is finished but i cannot publish package on nuget.org, waiting owner atm to do it.
If you want now, you can add feed https://www.myget.org/F/netcorecli-fsc-preview2-1/api/v3/index.json and will work

@enricosada ok, thanks for your info and cool that the work is more or less done. Looking forward to a new release ;)

Hi @KevinRansom, could you please take a look at the needed publishing steps in this project? Thanks a lot for your time and work here!

Hi @KevinRansom, @cartermp could one of you please pick up the nuget publish task for this project? At the moment you cannot compile an f# project on Dotnet Core 1.1 on Linux :(
If there is something in the way, what is needed to get it done? Anything I can do?

In addition to this issue: In my understanding netcorecli-fsc is more or less just a wrapper for Microsoft.FSharp.Compiler.netcore that actually has the fsc.exe in it. The preview 2-1 netcorecli-fsc references version 1.0.0-alpha-160831 of that package. When running "dotnet fsc.exe" in the lib/netstandard1.6 folder in Microsoft.FSharp.Compiler.netcore I get a "A fatal error was encountered. The library 'libhostpolicy.so' required to execute the application was not found in '[userdir]/.nuget/packages/Microsoft.FSharp.Compiler.netcore/1.0.0-alpha-160831/lib/netstandard1.6'.". Is this expected? I see the same with version 1.0.0-alpha-161205 of the Microsoft.FSharp.Compiler.netcore which is the latest on nuget.

Furthermore looking at https://github.com/Microsoft/visualfsharp/blob/master/src/fsharp/Fsc/project.json this project is still on netcore1.0. Is an upgrade there to netcore1.1 not prerequisite?
I have dotnet core 1.1 only on my machine, no side-by-side installation with 1.0.

@jp7677 you cannot atmdotnet fsc.exe from package becuase it doesn't have the right format atm.
Do dotnet -v build to see dotnet command line to run fsc.
Or publish Te package to have all you need in the directory.

About net1.1, it doesn't matter becuase1.0 is compatible with 1.1. Issue was the referenced package implementation (net.core.ap package) who was not embedded in cli ( so restore error )

Hi @enricosada, thanks for your info. just tested dotnet-compile-fsc-1.0.0-preview2.1-020105 with manual download and a local nuget repository. Everything is indeed fine with that version in a netcore 1.1 app, regardless that Fsc.exe wont work directly. Cool, thanks for your work!
Uploading that new version to nuget is really just the last thing missing.. :(

Surprising that it takes so long to roll out this fix to nuget. The fact that F# doesn't work out of the box in the current version of netcore strikes me as a serious issue, and is maybe even a little embarrassing. If there is any way to help speed things up, please let me know, I'd be happy to test, or contribute in other ways as needed.

@jschiefer is ok. There was a big release today, dotnet team was really busy last week, next time will be better, one fix/improvement at time :D

Btw, use LTS preview2 (project.json based) or preview4 (msbuild based) meanwhile.
.net 1.1 is not much more than 1.0 feature wise (perf/distro), so preview2.1 is a minor stuff. Preview2 LTS will continue to be supported and fixed

@jschiefer The problem is all ours. @enricosada has been ready to roll this out for a while, but the package he needs to update is owned by the dotnet team. We are working on getting the ownership fixed.

Thanks a lot @KevinRansom and @enricosada for the updates! I appreciate all the good work that is going into this. I have gone back for preview2 for the time being.

Thx to @KevinRansom now i can publish the dotnet-compile-fsc package on nuget.org 🎉

But bad news, nuget.org website doesnt support the package version string used (unlike nuget cli commands, local feed, and myget.org where i tested the package).

Long story short, i need to change package version because 1.0.0-preview2.1 is not supported on nuget.org website atm (the dot in -preview2.1 is not). That mean also dotnet new templates are wrong 😭 😭

Anyway a bit more of patience, and i'll publish an 1.1.0-preview2-something package.

Le sigh

Has any progess been made? It's been 2 months.

P.S. 🤦

I'm also waiting for this. It would be really nice to have this fixed so that people could get started with f# easily

Thanks

Is there at least a simple work around to get a F# project running on dotnet core?
Will an older version of dotnet core work?

Yes, there is. The version released here (https://github.com/dotnet/netcorecli-fsc/releases/tag/v1.0.0-preview2.1-020105) works just fine with the current Dotnet Core 1.1 version.
Just download the nuget package from here, copy it into a local folder and modify your NuGet.config to use that folder as repository.

Example:
Local folder: https://github.com/jp7677/hellocoreclr/tree/master/src/lib
NuGet.config: https://github.com/jp7677/hellocoreclr/blob/master/NuGet.Config
Project file: https://github.com/jp7677/hellocoreclr/blob/master/src/HelloCoreClrApp.Rules/project.json

See also https://github.com/dotnet/netcorecli-fsc/wiki/.NET-Core-SDK-preview2.1

Hi! Is this up yet, by any chance? I'm facing the same issue right now, where there's a mismatch between 1.0.0 and 1.1.0.

Oh hell, I should have checked the wiki. Thanks a lot 💃

I am going to close this issue.

There is a non invaside workaround in https://github.com/dotnet/netcorecli-fsc/wiki/.NET-Core-SDK-preview2.1#dotnet-new just add a nuget.config with dev feed

I cannot fix this, because the preview2.1 sdk is not going to be update anymore, so:

  • i cannot fix the dotnet new template
  • i cannot publish the same version 1.0.0-preview2-1-xxx on nuget.org (see previous comment about semver support in nuget.org)

Anyway that's going to be deprecated in favor of msbuild based (that's where all the effort is going atm for me too), ref https://github.com/dotnet/netcorecli-fsc/wiki/.NET-Core-SDK-rc3