You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Solution using type providers targeting F# 4.0.0.1 nuget does not build in VS2017 #3049
I have a solution that was created in VS2015 with two projects: -
F# class library, Services, which targets F#4.0.
C# ASP .NET application that references the F# library
Both have a paket reference to FSharp.Core4.0.0.1.
The solution builds fine in VS2015, yet having installed VS2017 I now get the following error whenever I try to build the C# application in VS2017: -
Error CS1705 Assembly 'Services' with identity 'Services, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'FSharp.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'FSharp.Core' with identity 'FSharp.Core, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
This is on a fresh VS2017 install with latest F# Nightly tools. The only way I can get it to build is through MSBuild directly in a FAKE script.
Just a small addendum - a full solution rebuild does still work in VS2015. But if you try a solution rebuild in VS2017 and then try to build the C# project (even from VS2015), it fails. It's as if the F# project is somehow being built linked against F#4.1 even though the referenced FSharp.Core is 4.0.
changed the title [-]Installing VS2017 has broken build of my project[/-][+]Hybrid C# / F# VS 2015 solution does not build in VS2017[/+]on May 13, 2017
open a vs command window, and run msbuild in the services directory. Scroll back through the output spew and find the compile options. it is similar to the below.
Can you see if there is an -r: for fsharp.core.dll it should look similar to this:
So it is there. I'm not sure if this means it's the same as #2399 or not though - your first comment suggest that that's not the case but your second implies it is :-)
So the build and compiler are referencing the correct FSharp.Core.dll. So the likely culprit is using a type that references the latest FSharp.Core.dll. The most likely cause is a bug in the TypeProvider. It worked as you expected in earlier versions of the FSharp.Compiler because of a bug in the Compiler that has been fixed.
The provided types file for that TP looks quite old. Perhaps someone familiar with the TP should try and fix the FSharp.Core types that it returns to the compiler.
I think this is a by design … It is an instance of where imported references were not unifying upwards. We have to have this behavior for two reasons:
Because it is the correct behavior
Because on the coreclr, it is entirely possible for an app to reference an unbound number of versions of bcl reference assemblies.
Someone needs to work with the SqlProvider maintainers to fix the issue in their type provider. I would try to take a look at it, but I kind of have a thousand other things to do right now. As I am sure does everyone else …
I do think there is, an F# compiler bug here too and that is we don’t issue an error message that the developer hasn’t referenced the unified version of the impacted assembly. However, that still wouldn't make this work.
There are tools in providedtypes.fs that enable a TP developer to pass back to the compiler the correct types for the references passed to the compiler. However, a lot of care is required and it is easy to get it wrong.
@dsyme@KevinRansom ok - thanks for explaining that :-) So what are the options going forward?
Someone updates the TP - sounds like a bit of effort but doable. I imagine only people that are using VS2017 / F#4.1 will be motivated to do this, but given the difficulty of working with TPs, this could be an issue for users of the TP.
Some change to allow the "old" behaviour? Or is that not possible / undesirable?
What is the impact of this issue vis-a-vis TPs in general - is it going to affect all of them? Just certain ones? Because of the spurious nature of this error I can see lots of people raising false positives about this.
I don't understand that much of this, but I do see similarities with an issue (or issues, it begins to look like) that I reported on Stackoverflow some time ago, and found a solution for. @isaacabraham, perhaps you can have a look at it and see if what I found can be of any help. Also, anybody, should I report that issue here?
@isaacabraham from my limited experience, this affects every type provider I have used, and will likely affect most others.
While I was trying to do my part by researching the behavior and providing more info for #2399, I found that I was able to create a provided property that returns an empty string or calls functions without any problems, but as soon as the property getter body uses anything specific to F#, even just the |> operator, the compiled binary points to the newer FSharp.Core again.
This is just my assumption, but I doubt many type providers were written with the intent to completely avoid all F# features in the provided members, and as @dsyme pointed out here, the solution to this is not well-documented.
@amazingant.
Yes if you pass back a type from the ambient FSharp.Core.dll which is super easy to do. Then the F# compiler is going to say ... oh I have a reference to FSharp.Core.dll version 4.4.1.0. Now all references to FSharp.Core in generated code will now use the higher version number and the referenced assembly will be to FSharp.Core version 4.4.1.0.
changed the title [-]Hybrid C# / F# VS 2015 solution does not build in VS2017[/-][+]Solution using type providers does not build in VS2017[/+]on Jun 20, 2017
changed the title [-]Solution using type providers does not build in VS2017[/-][+]Solution using type providers targeting F# 4.0.0.1 nuget does not build in VS2017[/+]on Jun 20, 2017
@dsyme is there a well-documented fix for this that could be applied to type providers for this? Or is it essentially "you must upgrade to FSharp.Core 4.1"?
Activity
isaacabraham commentedon May 13, 2017
The only way I've managed to actually get VS to build is to upgrade to FSharp.Core 4.1.
KevinRansom commentedon May 13, 2017
@isaacabraham
Can you add the project file for services?
isaacabraham commentedon May 13, 2017
Thanks Kev - it's here. I've removed the names of the .fs files in the main ItemGroup but otherwise this is it.
isaacabraham commentedon May 13, 2017
Just a small addendum - a full solution rebuild does still work in VS2015. But if you try a solution rebuild in VS2017 and then try to build the C# project (even from VS2015), it fails. It's as if the F# project is somehow being built linked against F#4.1 even though the referenced FSharp.Core is 4.0.
[-]Installing VS2017 has broken build of my project[/-][+]Hybrid C# / F# VS 2015 solution does not build in VS2017[/+]0x53A commentedon May 14, 2017
I think you are hitting #2399 - do you reference a type-provider in your F# project?
Edit: It looks like you use
FSharp.Data.SqlClient? Afaik, the only way to fix this, as you noticed, is to upp the version of FSharp.Core...KevinRansom commentedon May 14, 2017
@isaacabraham
open a vs command window, and run msbuild in the services directory. Scroll back through the output spew and find the compile options. it is similar to the below.
Can you see if there is an -r: for fsharp.core.dll it should look similar to this:
Please let me know if there is one. My intuition is that for the Services dll it is missing.
KevinRansom commentedon May 14, 2017
If there is an explicit reference to:
Then the issue is likely as @0x53A says the TypeProvider.
isaacabraham commentedon May 14, 2017
@KevinRansom Here's a snippet of output (taken from VS2017 command prompt): -
So it is there. I'm not sure if this means it's the same as #2399 or not though - your first comment suggest that that's not the case but your second implies it is :-)
isaacabraham commentedon May 14, 2017
Note that even in the VS2015 command prompt I see the
-rfor FSharp.Core.KevinRansom commentedon May 15, 2017
So the build and compiler are referencing the correct FSharp.Core.dll. So the likely culprit is using a type that references the latest FSharp.Core.dll. The most likely cause is a bug in the TypeProvider. It worked as you expected in earlier versions of the FSharp.Compiler because of a bug in the Compiler that has been fixed.
The fix is to correct the issue in the TP ...
Kevin
KevinRansom commentedon May 15, 2017
The provided types file for that TP looks quite old. Perhaps someone familiar with the TP should try and fix the FSharp.Core types that it returns to the compiler.
KevinRansom commentedon May 15, 2017
@isaacabraham
I think this is a by design … It is an instance of where imported references were not unifying upwards. We have to have this behavior for two reasons:
Someone needs to work with the SqlProvider maintainers to fix the issue in their type provider. I would try to take a look at it, but I kind of have a thousand other things to do right now. As I am sure does everyone else …
I do think there is, an F# compiler bug here too and that is we don’t issue an error message that the developer hasn’t referenced the unified version of the impacted assembly. However, that still wouldn't make this work.
There are tools in providedtypes.fs that enable a TP developer to pass back to the compiler the correct types for the references passed to the compiler. However, a lot of care is required and it is easy to get it wrong.
@dsyme thoughts?
dsyme commentedon May 15, 2017
@KevinRansom @isaacabraham I do believe the type provider may need to be updated to be a multi-targeting type provider, by making use of
ProvidedTypesContexthere: https://github.com/fsprojects/FSharp.TypeProviders.StarterPack/blob/master/src/ProvidedTypesContext.fsThis is non-trivial and, given the fairly sophisticated nature of that type provider, it may expose further issues.
3 remaining items
isaacabraham commentedon May 16, 2017
@dsyme @KevinRansom ok - thanks for explaining that :-) So what are the options going forward?
Someone updates the TP - sounds like a bit of effort but doable. I imagine only people that are using VS2017 / F#4.1 will be motivated to do this, but given the difficulty of working with TPs, this could be an issue for users of the TP.
Some change to allow the "old" behaviour? Or is that not possible / undesirable?
What is the impact of this issue vis-a-vis TPs in general - is it going to affect all of them? Just certain ones? Because of the spurious nature of this error I can see lots of people raising false positives about this.
BentTranberg commentedon May 19, 2017
I don't understand that much of this, but I do see similarities with an issue (or issues, it begins to look like) that I reported on Stackoverflow some time ago, and found a solution for. @isaacabraham, perhaps you can have a look at it and see if what I found can be of any help. Also, anybody, should I report that issue here?
Link to the issue on Stackoverflow:
"Cannot resolve dependency to assembly FSharp.Core 4.4.1.0 when using VS 2017"
http://stackoverflow.com/questions/42665926/cannot-resolve-dependency-to-assembly-fsharp-core-4-4-1-0-when-using-vs-2017
isaacabraham commentedon May 22, 2017
@BentTranberg Could be, but that looks more like a more run-of-the-mill binding redirects error to me.
allykzam commentedon May 22, 2017
@isaacabraham from my limited experience, this affects every type provider I have used, and will likely affect most others.
While I was trying to do my part by researching the behavior and providing more info for #2399, I found that I was able to create a provided property that returns an empty string or calls functions without any problems, but as soon as the property getter body uses anything specific to F#, even just the
|>operator, the compiled binary points to the newer FSharp.Core again.This is just my assumption, but I doubt many type providers were written with the intent to completely avoid all F# features in the provided members, and as @dsyme pointed out here, the solution to this is not well-documented.
KevinRansom commentedon May 22, 2017
@amazingant.
Yes if you pass back a type from the ambient FSharp.Core.dll which is super easy to do. Then the F# compiler is going to say ... oh I have a reference to FSharp.Core.dll version 4.4.1.0. Now all references to FSharp.Core in generated code will now use the higher version number and the referenced assembly will be to FSharp.Core version 4.4.1.0.
allykzam commentedon May 22, 2017
@KevinRansom as I mentioned, I was able to trigger this behavior by just using an F# operator within a provided property getter.
[-]Hybrid C# / F# VS 2015 solution does not build in VS2017[/-][+]Solution using type providers does not build in VS2017[/+][-]Solution using type providers does not build in VS2017[/-][+]Solution using type providers targeting F# 4.0.0.1 nuget does not build in VS2017[/+]isaacabraham commentedon Sep 29, 2017
@dsyme is there a well-documented fix for this that could be applied to type providers for this? Or is it essentially "you must upgrade to FSharp.Core 4.1"?
dsyme commentedon Sep 30, 2017
@isaacabraham My understanding is that the fix is to make the relevant type provider be a cross-targeting type provider. https://github.com/fsprojects/FSharp.TypeProviders.StarterPack#the-providedtypes-api---cross-targeting-type-providers. That's why the bug is currently labelled as external.
cartermp commentedon Jul 29, 2018
Closing as this has a solution that is external to this repo