Using F# with .NET Core 2.0 Part 1

With the release of .NET Core 2.0 I decided to try using it along with Visual Studio Code. Keep in mind, that I'm doing this on Windows. I also used this blog as a reference, but talks about installing .NET Core 2.0 on the Mac.

First, you can install .NET Core 2.0 by downloading it from here. While downloading/installing, make sure you have Visual Studio Code installed along with the Ionide plugin. After the install is complete, you can create a new project using the dotnet command in command line. I created a new project called Project.Moo.Foo (a naming convention a coworker likes so I'm borrowing it) like so:

These commands are important:

dotnet new sln -n Project.Moo

dotnet new classlib -o Project.Moo.Foo -lang f#

dotnet sln add Project.Moo.Foo/Project.Moo.Foo.fsproj

dotnet build

  • The first command will create the sln file.
  • The second command will create a class project and set F# as the default language
  • The third will create the fsproj file and then add it to the sln file.
  • The last command will build it and that's it!

Now that a solution with a library project has been created, let's add a fsx file. You can do this by using Visual Studio Code. First create a new file and save it as a .fsx file. Make sure the file is saved in the appropriate directory. After that, hit the following keystroke ctrl + shift + p and then type in F# Add and select F#: Add Current File To Project. This will update the .fsproj file to include the new fsx file.

That's it for Part 1. The next part, I'll create a project that builds/runs on .NET Core 2!