fabulous-dev / Fabulous

Declarative UI framework for cross-platform mobile & desktop apps, using MVU and F# functional programming
https://fabulous.dev
Apache License 2.0
1.15k stars 122 forks source link

FSharp.Core is missing HintPath in the iOS template #776

Closed TimLariviere closed 3 years ago

TimLariviere commented 4 years ago

I have had the same exception on startup ( Could not load type of field 'Fabulous.ViewElement... Could not resolve type ...'Microsoft.FSharp.Core.FSharpValueOption etc) happen to me a couple of times this week, but on iOS instead. Android has been fine.

In each case I have tracked down the problem to this line in my fsproj:

    <Reference Include="FSharp.Core">
      <Private>True</Private>
    </Reference>

which needed to be replaced with

    <Reference Include="FSharp.Core">
      <HintPath>..\packages\FSharp.Core.4.7.2\lib\netstandard2.0\FSharp.Core.dll</HintPath>
    </Reference>

Originally posted by @Ryan-Palmer-CIT in https://github.com/fsprojects/Fabulous/issues/385#issuecomment-656587527

TimLariviere commented 4 years ago

@Ryan-Palmer-CIT I've duplicated your comment so we can track this. Could you add some context to it, please?

Just checked, both the Android and iOS projects include the HintPath in the templates.

teknikal-wizard commented 4 years ago

Sure no problem. I was going to add the issue as requested, sorry I hadn't managed to do it already it's just been a hectic week!

I just looked over the git history. My first commit was a clean Fabulous template installed and working. My second commit updates a few packages. In the iOS project, this caused FSharp.Core to become private. The same did not happen to the Android project.

iOS .fsproj

image

iOS packages.config

image

teknikal-wizard commented 4 years ago

On a side note, updating FSharpCore only updated the 'Update' refs in the core Forms project, ignoring the 'Include' one.

image

SergejDK commented 3 years ago

@Ryan-Palmer-CIT I think this issue is solved, right? I tested it and it seems to be fixed.

teknikal-wizard commented 3 years ago

Maybe, I haven't tried using Fabulous since I wrote this post. Sorry I can't be any more help!

SergejDK commented 3 years ago

That's not a problem. With the latest version of Fabulous and VS this does not seem to be a problem anymore. I am going to close this.

teknikal-wizard commented 3 years ago

Hi @SergejDK , sorry to raise this from the dead but I just came back to Fabulous after a few months and had exactly this happen again. It seems it may be Windows related, so if you try to replicate you will need to use that rather than mac OS.

Just create a new Fabulous template project and update FSharp Core, I went to 5.0.2. It should mess up the fsharp refs. You will get an exception saying it can't find a ValueTuple definition in an FSharp 4.7.2 folder. The solution is to open the ios project file and make the replacements tim mentioned in the OP (but with the newer 5.0.2 F# version).

TimLariviere commented 3 years ago

@Ryan-Palmer-CIT I think it's a tooling issue in Visual Studio rather than a Fabulous issue...

We do have the hint path for FSharp.Core correctly declared in the iOS project https://github.com/fsprojects/Fabulous/blob/ebcecbfcfcc598c9e8651b22f02652d2796f6ae6/Fabulous.XamarinForms/templates/content/blank/NewApp.iOS/NewApp.iOS.fsproj#L132-L134

How do you update the FSharp.Core package? Via the NuGet UI in VS? Does VS replace HintPath with Private = True?

One thing that can be a problem with FSharp.Core, is that it's both a NuGet package and a assembly reference coming from the .NET SDK. And that assembly reference is implicitly added to all fsproj, hence why we had to have <PackageReference Update="xxx"/> instead of just Include.

teknikal-wizard commented 3 years ago

Hi Tim! It is the same issue we went over before.

How do you update the FSharp.Core package? Via the NuGet UI in VS? Does VS replace HintPath with Private = True?

Yes and yes.

TimLariviere commented 3 years ago

Maybe the folks at https://github.com/xamarin/xamarin-macios can help fix that behavior?

teknikal-wizard commented 3 years ago

Do you think it is worth a note in the docs or something? I lost many hours to it and I think it will happen to every Windows VS user!

TimLariviere commented 3 years ago

I think we can include a note on it on this page: https://fsprojects.github.io/Fabulous/Fabulous.XamarinForms/dev-pitfalls.html I already added some notes on limitations about IDEs and F# 5.0 in it, so it should be a good place for this.

teknikal-wizard commented 3 years ago

Ok great - would you like me to add it or would you rather?

TimLariviere commented 3 years ago

It would be great if you could do it :) I'll merge as soon as I have some time.

teknikal-wizard commented 3 years ago

No problem, thanks for your help :)

teknikal-wizard commented 3 years ago

Done https://github.com/fsprojects/Fabulous/pull/890