Opening 2 years old project in visual studio

Hi

Recently I switched to windows and I decided that it’s a good opportunity to lean F#. I peaked up the Get Programming with F# book and started reading. One of the project in the book is this one. However when I opened it in Visual Studio 2019 and tried to build it I got the following error:

|Error||Unknown build error, 'Cannot resolve dependency to assembly 'FSharp.Core, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.'|MonopolyGui||||

This corresponds directly with one of my fears of .Net programming - It’s too tied up to the specific environment and IDE. I’m not against working in IDE (although I prefer editors like VSCode) - I’m really against requiring an IDE to build the project …

So I have several questions:

  • Is there a relatively easy way to open and build this project?
  • How can I list what F# versions I have installed?
  • I know that you can edit new F# projects in VSCode but I also heard about requiring Visual Studio if you want to build in certain frameworks (like building for android). So if I mainly want to use F# for command line tools and cross platform GUI applications (Avalonia?) will I have to build it on visual studio or can I use VSCode?

Thanks in advance

Haim

I can’t speak to Android as I’ve never tried to target it. However, there’s nothing about command-line applications or Avalonia that requires Visual Studio (AFAIK). In order to have a “smooth” time with F# (on any platform), I’d recommend staying away from .NET Framework (if possible) and only using .NET Core (3.x) or .NET 5 (and up). In either case, you’ll want to install the relevant SDKs from here:

As far as checking versions of things, a good starting point is to run the command:

> dotnet --info

from whatever console environment you like to use.

Try using NuGet to adding a dependency to FSharp.Core (an older version from before the time that this sample was created). It is a best practice in general to add FSharp.Core as an explicit dependency for this reason, rather than using the version inferred by the currently installed tooling.

That’s great to hear

Yup, that was my feeling also :slightly_smiling_face:

ahhhh, this is really helpful, thanks.

I also managed to build the project after I installed a similar Fsharp.Core version from nuget (it doesn’t seem to have 4.4…).

Great, thanks for the info.

Thanks, this is what I finally did when I figured out that Fsharp.Core was not the fsharp version on my laptop but a dependency :slightly_smiling_face: (did I mention I’m a newbie?)

You can’t have 2 solutions selected :frowning_face:

Thanks @Prash and @pblasucci , both of your answers helped.

1 Like