Skip to content

FSharp.Core Conflicts MSBuild 15.6 #4517

Closed

Description

@BlythMeister

Since updating to MSBuild 15.6 our build process reports warnings with a conflict on FSharp.Core.

For some reason, it has started trying to use version 4.4.3.0 of FSharp.Core.
The nuget package for FSharp.Core we are pulling is 4.4.1.0.

It seems that there is some Unification happening:

31>		Unified Dependency "FSharp.Core, Version=4.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
31>		    Using this version instead of original version "4.3.0.0" in "F:\GIT\Source\packages\FSharp.Data.TypeProviders\lib\net40\FSharp.Data.TypeProviders.dll" because AutoUnify is 'true'.
31>		    Using this version instead of original version "4.3.0.0" in "F:\GIT\Source\packages\FSharpx.Core\lib\40\FSharpx.Core.dll" because AutoUnify is 'true'.
31>		    Using this version instead of original version "4.3.1.0" in "F:\GIT\Source\packages\FsUnit\lib\net45\FsUnit.NUnit.dll" because AutoUnify is 'true'.
31>		    Resolved file path is "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\PublicAssemblies\FSharp.Core.dll".
31>		    Reference found at search path location "{AssemblyFoldersFromConfig:C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\AssemblyFolders.config,v4.5}".
31>		        For SearchPath "F:\GIT\Source\Code\[REDACTED]\bin\Debug".
31>		        Considered "F:\GIT\Source\Code\[REDACTED]\bin\Debug\FSharp.Core.winmd", but it didn't exist.
31>		        Considered "F:\GIT\Source\Code\[REDACTED]\bin\Debug\FSharp.Core.dll",
31>			but its name "FSharp.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
31>			didn't match the expected name "FSharp.Core, Version=4.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
31>		        Considered "F:\GIT\Source\Code\[REDACTED]\bin\Debug\FSharp.Core.exe", but it didn't exist.
31>		        For SearchPath "{TargetFrameworkDirectory}".
31>		        Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\FSharp.Core.winmd", but it didn't exist.
31>		        Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\FSharp.Core.dll", but it didn't exist.
31>		        Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\FSharp.Core.exe", but it didn't exist.
31>		        Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades\FSharp.Core.winmd", but it didn't exist.
31>		        Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades\FSharp.Core.dll", but it didn't exist.
31>		        Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades\FSharp.Core.exe", but it didn't exist.
31>		        For SearchPath "{AssemblyFoldersFromConfig:C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\AssemblyFolders.config,v4.5}".
31>		        Considered "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\Microsoft\SqlDb\FSharp.Core.winmd", but it didn't exist.
31>		        Considered "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\Microsoft\SqlDb\FSharp.Core.dll", but it didn't exist.
31>		        Considered "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\Microsoft\SqlDb\FSharp.Core.exe", but it didn't exist.
31>		        Considered "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\PublicAssemblies\FSharp.Core.winmd", but it didn't exist.

Which then leads it to this warning a bit later in the build process

31>		There was a conflict between "FSharp.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "FSharp.Core, Version=4.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
31>		    "FSharp.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "FSharp.Core, Version=4.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
31>		    References which depend on "FSharp.Core, Version=4.4.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [F:\GIT\Source\packages\FSharp.Core\lib\net45\FSharp.Core.dll].
31>		        F:\GIT\Source\packages\FSharp.Core\lib\net45\FSharp.Core.dll
31>		          Project file item includes which caused reference "F:\GIT\Source\packages\FSharp.Core\lib\net45\FSharp.Core.dll".
31>		            FSharp.Core
31>		    References which depend on "FSharp.Core, Version=4.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\PublicAssemblies\FSharp.Core.dll].
31>		        F:\GIT\Source\packages\FSharpx.Core\lib\40\FSharpx.Core.dll
31>		          Project file item includes which caused reference "F:\GIT\Source\packages\FSharpx.Core\lib\40\FSharpx.Core.dll".
31>		            F:\GIT\Source\Code\[REDACTED]\bin\Debug\[REDACTED].dll
31>		            FSharpx.Core
31>		        F:\GIT\Source\packages\FSharp.Data.TypeProviders\lib\net40\FSharp.Data.TypeProviders.dll
31>		          Project file item includes which caused reference "F:\GIT\Source\packages\FSharp.Data.TypeProviders\lib\net40\FSharp.Data.TypeProviders.dll".
31>		            FSharp.Data.TypeProviders
31>		        F:\GIT\Source\packages\FsUnit\lib\net45\FsUnit.NUnit.dll
31>		          Project file item includes which caused reference "F:\GIT\Source\packages\FsUnit\lib\net45\FsUnit.NUnit.dll".
31>		            FsUnit.NUnit
31>		        F:\GIT\Source\Code\[REDACTED]\bin\Debug\[REDACTED].dll
31>		          Project file item includes which caused reference "F:\GIT\Source\Code\[REDACTED]\bin\Debug\[REDACTED].dll".
31>		            F:\GIT\Source\Code\[REDACTED]\bin\Debug\[REDACTED].dll
31>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2052,5): warning MSB3277: Found conflicts between different versions of "FSharp.Core" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed.

I'm not sure if this is a FSharp.Core or a MSBuild issue.
But since we are only seeing this issue with the FSharp.Core dependency, i thought it best to start here.

Activity

  1. dsyme commented on Mar 14, 2018

    @dsyme
    Contributor

    Can you show us the project file for the relevant project please?

  2. BlythMeister commented on Mar 14, 2018

    @BlythMeister
    Author

    I'm trying to create a minimal viable repo of this which doesn't include any of my orgs closed source items.

  3. dsyme commented on Mar 14, 2018

    @dsyme
    Contributor

    Specifically just the Reference ItemGroup (ignoring all your own references)

  4. BlythMeister commented on Mar 14, 2018

    @BlythMeister
    Author

    Projects.zip

    This is the project files and paket.lock file i have

  5. dsyme commented on Mar 14, 2018

    @dsyme
    Contributor

    I don't know why, but the HintPath references to FSharpx.Core and FSharp.Data.TypeProviders DLLs are causing an implicit reference to FSharp.Core to be added.

    Something these packages have in common is that they don't correctly express their dependency on the FSharp.Core package since they are "old" F# packages from before the FSharp.Core nuget was finalized. However I don't see why referencing them should cause an implicit FSharp.Core reference. @KevinRansom Do you know why?

    You might get mileage from

    <DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
    
  6. BlythMeister commented on Mar 14, 2018

    @BlythMeister
    Author

    where do you add that xml?

    Also, FSUnit is also causing a unification, but it does state the FSharp.Core in the nuget...

  7. BlythMeister commented on Mar 14, 2018

    @BlythMeister
    Author

    MinimalFSharpRepo.zip

    This example needs a paket restore and build and when you look at the diagnostic build log you will see the warning

    2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2052,5): warning MSB3277: Found conflicts between different versions of "FSharp.Core" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed.
    

    It's the most simple example i could make with literally none of our code in it.
    All code is for loading references

  8. dsyme commented on Mar 14, 2018

    @dsyme
    Contributor

    You want this in all your project files:

    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    

    That makes everything work OK I believe. I don't really know how/why the FSharp.Core 4.4.3.0 reference was being generated though

  9. BlythMeister commented on Mar 14, 2018

    @BlythMeister
    Author

    @dsyme I don't fully understand, Paket has already created the binding redirect in app.config. cc @forki

  10. Zagrophyte commented on Mar 14, 2018

    @Zagrophyte

    @BlythMeister In your example repo, there is a property called:
    <TargetFSharpCoreVersion>4.3.0.0</TargetFSharpCoreVersion>
    In my experience this comes from the standard F# project template. I suspect that is what will be overriden by the DisableImplicitFSharpCoreReference entry that Don is suggesting.

  11. Zagrophyte commented on Mar 14, 2018

    @Zagrophyte

    These entries live in the PropertyGroup sections within each fsproj.

  12. BlythMeister commented on Mar 14, 2018

    @BlythMeister
    Author

    I tried adding the disable implicit to the top property group, but it still had the warning in the build log.
    Did I need to remove the target fsharp core version?

  13. dsyme commented on Mar 14, 2018

    @dsyme
    Contributor

    @BlythMeister I don't know the details, but

    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    

    causes MSBuild to behave the right way. It's what you want in my experience and I've not seen any trouble with it.

  14. BlythMeister commented on Mar 14, 2018

    @BlythMeister
    Author

    Ok, I'll give that a go.and report back.
    Do you just put that in all projects (regardless of language)?

  15. Zagrophyte commented on Mar 14, 2018

    @Zagrophyte

    Confirmed--adding Don's suggestion of <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> to the top PropertyGroup of each fsproj made the example repo build without warnings.

    To be thorough, I also tried <DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference> but it did not avoid the issue,

  16. dsyme commented on Mar 14, 2018

    @dsyme
    Contributor

    Do you just put that in all projects (regardless of language)?

    yes

  17. dsyme commented on Mar 14, 2018

    @dsyme
    Contributor

    Closing as this is some MSBuild thing

  18. BlythMeister commented on Mar 14, 2018

    @BlythMeister
    Author

    Not sure how I forgot about this...but raised feature request for Paket to do this automatically a while back....fsprojects/Paket#2573

  19. 0x53A commented on Mar 14, 2018

    @0x53A
    Contributor

    The hint path thing is a bit dangerous. If the dll can't be found at the hint path, it takes an arbitrary version from the GAC.

    Can you double check if the hint path exists?

  20. BlythMeister commented on Mar 14, 2018

    @BlythMeister
    Author

    Hint path definitely exists.

  21. xperiandri commented on Nov 13, 2021

    @xperiandri
    Contributor

    <DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>

    works for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions