dotnet / netcorecli-fsc

[DEPRECATED] F# and .NET Core SDK working together

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Console and classlib assemblies produced with references to conflicting versions of System.Runtime

aggieben opened this issue · comments

I ran into an issue this weekend trying to build a simple netcoreapp2.0 app. I've reproduced it with a minimal project, which is as follows.

There is a console project, called Console, and a classlib project called Classlib. Console has a reference to Library.

Here's the Console.fsproj:

<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Program.fs" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="../Library/Library.fsproj" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="FSharp.Core" Version="4.1.17" />
    <PackageReference Include="FSharp.NET.Sdk" Version="1.0.5" PrivateAssets="All" />
  </ItemGroup>

</Project>

The sources for Console:

open System
open Library

[<EntryPoint>]
let main argv =
    let result = Stats.ema 0.0 [3.7; 8.9]
    0 // return an integer exit code

The Library.fsproj:

<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Library.fs" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="FSharp.Core" Version="4.1.17" />
    <PackageReference Include="FSharp.NET.Sdk" Version="1.0.5" PrivateAssets="All" />
  </ItemGroup>

</Project>

And finally, Library.fs:

module Library.Stats

let ema (prevEma:float) (values:float list) =
    0.0

The projects build:

λ  dotnet build
Microsoft (R) Build Engine version 15.3.117.23532
Copyright (C) Microsoft Corporation. All rights reserved.

  Library -> C:\Users\ben\proj\scratch\fsharp-test\src\Library\bin\Debug\netstandard2.0\Library.dll
  Console -> C:\Users\ben\proj\scratch\fsharp-test\src\Console\bin\Debug\netcoreapp2.0\Console.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:02.19

But at runtime:

C:\Users\ben\proj\scratch\fsharp-test
λ  dotnet .\src\Console\bin\Debug\netcoreapp2.0\Console.dll

Unhandled Exception: System.MissingMethodException: Method not found: 'Double Library.Stats.ema(Double, Microsoft.FSharp.Collections.FSharpList`1<Double>)'.
   at Program.main(String[] argv)

After inspecting with ilspy I found that these two projects reference the same version of FSharp.Core, but different versions of System.Runtime:
screen shot 2017-05-30 at 7 57 37 am

screen shot 2017-05-30 at 7 57 51 am

My dotnet --info:

C:\Users\ben\proj\scratch\fsharp-test                              
λ  dotnet --info                                                   
.NET Command Line Tools (2.0.0-preview1-005977)                    
                                                                   
Product Information:                                               
 Version:            2.0.0-preview1-005977                         
 Commit SHA-1 hash:  414cab8a0b                                    
                                                                   
Runtime Environment:                                               
 OS Name:     Windows                                              
 OS Version:  10.0.15063                                           
 OS Platform: Windows                                              
 RID:         win10-x64                                            
 Base Path:   C:\Program Files\dotnet\sdk\2.0.0-preview1-005977\   
                                                                   
Microsoft .NET Core Shared Framework Host                          
                                                                   
  Version  : 2.0.0-preview1-002111-00                              
  Build    : 1ff021936263d492539399688f46fd3827169983              

I've attached a copy of my minimal repro: fsharp-test.zip

FWIW, I did go back and try this with TargetFramework set to netstandard1.6 and netcoreapp1.1, and it seems to work.

the sdk2.0 (for netcoreapp2.0 is not supported).

closing as dupe of #108