isaacabraham / get-programming-fsharp

Companion code repository for https://www.manning.com/books/get-programming-with-f-sharp
124 stars 57 forks source link

Lesson 29 sample solution won't compile #5

Open red-swan opened 4 years ago

red-swan commented 4 years ago

Upon opening Capstone5.sln file in the /src/code-listings/lesson-29 folder or sample-solution subfolder in VIsual Studio 2017 or 2019, I get the following build error when trying to compile the solution.

1>------ Build started: Project: Core, Configuration: Debug Any CPU ------
2>------ Build started: Project: WpfClient, Configuration: Debug Any CPU ------
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "FSharp.Core, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
2>C:\Users\jdks\Code\F#\get-programming-fsharp-master\src\code-listings\lesson-29\sample-solution\WpfClient\WpfClient.csproj(121,5): error : This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\Fody.1.29.4\build\dotnet\Fody.targets.
1>      Core -> C:\Users\jdks\Code\F#\get-programming-fsharp-master\src\code-listings\lesson-29\sample-solution\Core\bin\Debug\Core.dll
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I'm not a .NET expert, so I don't know how to resolve this. Is there a fix for this?

isaacabraham commented 4 years ago

Hey. Let me have a look into this this week - most likely it's just that VS2017 and 2019 work slightly different in terms of NuGet than 2015 did and that there was a breaking change (at least, that's what it appears).

I don't even have 2015 installed anymore so I'll give this a go to see what's wrong - sorry about that!

red-swan commented 4 years ago

No worries! Book's great. I await your investigation.

isaacabraham commented 4 years ago

@red-swan can you pull the latest version and try again? I think it was just that the project was targetting an older version of .NET Framework (4.5) and it needed to be upgraded to a later version (4.7.2). It should work now.

red-swan commented 4 years ago

I tried building the solution in VS2017 and VS2019. Building the F# Core project goes through smoothly. When I try to build the WpfClient project, I get the same error in both IDEs:

Severity    Code    Description Project File    Line    Suppression State
Error       Unknown build error, 'Cannot resolve dependency to assembly 'FSharp.Core, Version=4.7.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.'   WpfClient           
isaacabraham commented 4 years ago

What version of VS2019 and .NET Framework do you have installed?

red-swan commented 4 years ago

VS 2019 16.3.2 VS2017 15.9.16 Using this article I find that I have .NET 4.8 installed.

red-swan commented 4 years ago

When I open the solution in, there's a yellow arrow on the FSharp.Core reference. image

red-swan commented 4 years ago

I edited Core.fsproj to change FSharp.Core's version to be 4.5.0.0 and then added a reference to that version in both projects and it compiled just fine. .NET makes no sense to me!