2

Trying to make dotnet-fantomas work, I installed both Fantomas and dotnet-fantomas from Nuget and added the lines

<ItemGroup>  
    <DotNetCliToolReference Include="dotnet-fantomas" Version="2.7.1" />
</ItemGroup>

to my .fsproj file. Then I added the folder where dotnet-fantomas.exe was installed to the Windows path.

Next I opened a command prompt in a folder with some .fs files and tried to run

dotnet-fantomas Asset.fs --force

I got the error message below. dotnet-fantomas is asking for FSharp.Core, Version=4.4.1.0 and I have FSharp.Core version 4.3.4. Browsing in the Nuget Package Manager that is the latest version available. My project has 4.4.3.0 as Target runtime and .NET Framework 4.6.1 as Target Framework.

What am I missing?

C:\Projects\bitbucket3\VSProjects\Fractal13\Fractal13>dotnet-fantomas Asset.fs --force
The following exception occurs while formatting stdin: System.IO.FileLoadException: Could not load file or assembly 'FSharp.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'FSharp.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at Fantomas.CodeFormatterImpl.createFormatContextNoChecker(String fileName, String source)
   at Fantomas.CodeFormatter.FormatDocument(String fileName, String source, FormatConfig config)
   at Fantomas.Cmd.Program.processSourceString(Boolean isFsiFile, String s, TextWriter tw, FormatConfig config)
   at Fantomas.Cmd.Program.stringToFile@185(FSharpRef`1 force, FSharpRef`1 profile, FSharpRef`1 fsi, String s, String outFile, FormatConfig config)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Force writing original contents to Asset.fs.
Soldalma
  • 4,636
  • 3
  • 25
  • 38
  • 2
    The *package* version isn't the same as the DLL version. Do you have a bad redirect in your app.config perhaps? Which version of Visual Studio are you using? The latest is VS 2017 15.7. There were quite a few problems with version mixups about a year ago, check [this similar question](https://stackoverflow.com/questions/42665926/cannot-resolve-dependency-to-assembly-fsharp-core-4-4-1-0-when-using-vs-2017) – Panagiotis Kanavos May 08 '18 at 12:05
  • I am using VS 2017 15.7, which I downloaded yesterday. My app.config has only the following: ` – Soldalma May 08 '18 at 12:11
  • I looked at the question you suggested. One comment by Bent Tranberg has the following: "your problem could simply be that you need to add a reference to FSharp.Core 4.4.1.0 (Not Microsoft.FSharp...) in your C# project(s) where this error appears. " This looks interesting but is a bit over my head. I do not know how to do it. – Soldalma May 08 '18 at 12:29
  • 2
    That's because F# versioning is [a mess](https://github.com/fsharp/fslang-design/blob/master/tooling/FST-1004-versioning-plan.md) – Szer May 08 '18 at 13:30
  • 1
    Mind-boggling. How can a mere mortal without superpowers handle this? – Soldalma May 08 '18 at 14:10

0 Answers0