I noticed that adding packages sometimes breaks my code. Functions like Seq.replicate and List.take that were working get red squiggly lines and the program no longer runs. Here is a detailed procedure that should replicate the problem (I am using VS Community Edition 2017):
1) Create a project.
2) Program.fs contains the code:
[<EntryPoint>]
let main argv =
printfn "%A" argv
0 // return an integer exit code
3) Add two lines of code as follows:
[<EntryPoint>]
let main argv =
let repla = Seq.replicate 10 "A"
printfn "%A" (repla |> List.ofSeq |> List.take 5)
printfn "%A" argv
0 // return an integer exit code
3) Hit Ctrl+F5, the program runs without any problems.
4) Right-click on References on the Solution Explorer. Click on Manage Nuget Packages....
5) Click on Browse.
6) Search for Newtonsoft.Json and install it.
7) Hit Ctrl+F5, the program runs without any problems. The console prints
["A"; "A"; "A"; "A"; "A"]
[||]
8) Proceed as in steps 4 to 6 and install package MathNet.Numerics using Nuget.
9) Hit Ctrl+F5, the program runs without any problems. The console prints
["A"; "A"; "A"; "A"; "A"]
[||]
10) Proceed as in steps 4 to 6 and install package MathNet.Numerics.FSharp using Nuget.
11) Click on the Program.fs tab. The dreaded red squiggly lines appeared under Seq.replicateandList.take`.
12) Hit Ctrl+F5. A dialog box pops up with the following message:
There were build errors. Would you like to continue and run the last successful build?
Questions:
a) What exactly is happening?
b) Is this an isolated case related to a problem in MathNet.Numerics.FSharp or the specific combination of packages installed, or the order in which they were installed? Or is this a common problem?
c) Is it possible to avoid this problem while using Nuget?
d) If not, is it possible to avoid this problem by installing by some other means (not Nuget)?
MathNet.Numerics.FSharp has a dependency to FSharp.Core.3.1.2.5 which replaces the current version of FSharp.Core you are using. Being quite old 3.1.2.5 lacks many functions.
This happens with other popular F# libraries such as FsCheck as well. I usually change the reference to the newest version of FSharp.Coreas that should be backward compatible.
To do so I unload the F# project and update the FSharp.Core reference in the project file to:
<Reference Include="FSharp.Core">
<Name>FSharp.Core</Name>
<AssemblyName>FSharp.Core.dll</AssemblyName>
<HintPath>$(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\$(TargetFSharpCoreVersion)\FSharp.Core.dll</HintPath>
</Reference>
Then I reload the project.
As this is a rather clunky procedure hopefully more insightful users will post a better solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With