Bug 59879 - Compiler error given when using F# Xamarin Forms Shared template: FileNotFoundException: Could not load assembly 'FSharp.Core, Version=4.4.1.0
Summary: Compiler error given when using F# Xamarin Forms Shared template: FileNotFoun...
Status: RESOLVED DUPLICATE of bug 58371
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Android Add-in (show other bugs)
Version: 7.1 (d15-3)
Hardware: PC Mac OS
: --- normal
Target Milestone: master
Assignee: Greg Munn
URL:
Depends on:
Blocks:
 
Reported: 2017-10-01 08:33 UTC by Andres G. Aragoneses
Modified: 2017-10-04 00:35 UTC (History)
2 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description Andres G. Aragoneses 2017-10-01 08:33:14 UTC
Using VSforMac 7.1.5 (build 2)

Steps to reproduce:
1. Launch VSforMac.
2. Click on New Project... choose MultiPlatform -> App -> Blank Forms App
3. Select F# language, Next.
4. App name: foo
5. Organization identifier: bar.baz
6. Leave both Android and iOS platform options checked.
7. Choose Shared Library.
8. Leave XAML checkbox checked.
9. Project name: foo. Solution name: foo.
10. Click on Create button.
11. Right click the foo.Droid project -> Build foo.Droid.

Expected results: should build successfully.

Current results:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2,2): Error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'FSharp.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'FSharp.Core.dll'
  at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference, Mono.Cecil.ReaderParameters parameters) [0x00099] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:225 
  at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference reference) [0x00000] in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:175 
  at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver, System.Collections.Generic.ICollection`1[T] assemblies, Mono.Cecil.AssemblyDefinition assembly, System.Boolean topLevel) [0x0015c] in <71817c867ffe4e03b7e1d40c989361dc>:0 
  at Xamarin.Android.Tasks.ResolveAssemblies.Execute (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver resolver) [0x0019c] in <71817c867ffe4e03b7e1d40c989361dc>:0  (foos.Droid)


Workaround A: in step 7, choose Portable library instead of Shared.

Workaround B: apply this diff to the .fsproj file (ugly and only compatible with Mac):
diff --git a/Foo/Droid/Foo.Droid.fsproj b/Foo/Droid/Foo.Droid.fsproj
index fa6ec52..885489c 100644
--- a/Foo/Droid/Foo.Droid.fsproj
+++ b/Foo/Droid/Foo.Droid.fsproj
@@ -16,6 +16,7 @@
     <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
     <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
     <AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
+    <TargetFSharpCoreVersion>4.4.1.0</TargetFSharpCoreVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
@@ -41,6 +42,10 @@
   </PropertyGroup>
   <Import Project="..\Foo\Foo.projitems" Label="Shared" Condition="Exists('..\Foo\Foo.projitems')" />
   <ItemGroup>
+    <Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+      <Private>True</Private>
+      <HintPath>/Library/Frameworks/Mono.framework/Versions/5.2.0/lib/mono/gac/FSharp.Core/4.4.1.0__b03f5f7f11d50a3a/FSharp.Core.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Xml" />
     <Reference Include="System.Core" />
Comment 1 Matt Ward 2017-10-01 13:17:08 UTC
This looks like bug #58371 which is fixed in 7.2 but not in 7.1. The problem is that in later Xamarin.Android versions FSharp.Core is not available so the FSharp.Core NuGet package should be installed by the project template.

*** This bug has been marked as a duplicate of bug 58371 ***
Comment 2 Andres G. Aragoneses 2017-10-04 00:35:55 UTC
Lol, sorry Matt I'm so dumb, it's the second dupe I file about this! (bug 59073 before).

Note You need to log in before you can comment on or make changes to this bug.