Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

F# support for latest asp.net 5 and MVC6

I need to find a way of building rest services in F# using the latest asp.net 5 and mvc 6 web api. Is there any direct support for this in Visual Studio 2015 as a project template? If not, could someone please put me on the right track on how to proceed? One option could be to build an F# library and then call it from a C# asp.net mvc 6 project. However I would be very interested in building a native F# mvc 6 web api. Thanks!

Google returned the following project: https://github.com/fsprojects/fsharp-dnx

The HelloFSharp sample works fine, however could not manage to make the HelloMVC project build:

  • dnu restore complains about many not found dependencies
  • dnx web has the following error:

    System.TypeLoadException: Could not load type 'Microsoft.Extensions.Logging.ILogValues' from assembly 'Microsoft.Extensions.Logging.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
    
like image 973
BigONotation Avatar asked Feb 27 '16 12:02

BigONotation


1 Answers

F# is now supported by .net core. As of this writing, F# code can only be compiled with .net core 1.0.3 LTS. On Ubuntu 16.10, use the steps described here to add the .net core repo.

  • Make sure to install .net core 1.0.3 LTS (and not the latest .net core 1.1): sudo apt-get install dotnet-dev-1.0.0-preview2-003156
  • Create a directory for your F# project: mkdir helloworldfsharp and cd helloworldfsharp
  • In that directory: dotnet new -l f#. This will create a new F# project
  • dotnet restore. This will restore all packages and install the F# compiler.
  • dotnet build
  • dotnet run

Edit: The previous steps generates a console application. If you want to create a asp.net core mvc app, adapt the generated files as described here (as you see in the link, this is quite straightforward).

like image 187
BigONotation Avatar answered Sep 28 '22 06:09

BigONotation