Bug 59879 - Compiler error given when using F# Xamarin Forms Shared template: FileNotFoundException: Could not load assembly 'FSharp.Core, Version=
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
Depends on:
Reported: 2017-10-01 08:33 UTC by Andres G. Aragoneses
Modified: 2017-10-04 00:35 UTC (History)
2 users (show)

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

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

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=, 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 @@
+    <TargetFSharpCoreVersion></TargetFSharpCoreVersion>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -41,6 +42,10 @@
   <Import Project="..\Foo\Foo.projitems" Label="Shared" Condition="Exists('..\Foo\Foo.projitems')" />
+    <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/</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).