F# Compilation Failure: Multiple references to 'mscorlib.dll' are not permitted
See original GitHub issueI’m running into a scenario where adding a few NuGet packages to my F# function results in the following error being spit out multiple times during compilation:
2016-12-04T21:05:16.249 commandLineArgs(1,1): error FS215: Multiple references to 'mscorlib.dll' are not permitted
Here’s a project.json
that reproduces the issue:
{
"frameworks": {
"net46": {
"dependencies": {
"FSharp.Data": "2.3.2",
"FSharp.Data.SqlClient": "1.8.2",
"Microsoft.Azure.Search": "3.0.1"
}
}
}
}
It’s also worth noting that this happens regardless of what’s in the function itself, so is caused simply by adding the references.
Repro steps
-
Create a new F# function
-
Add the
project.json
file above -
💥
Expected behavior
The function should compile
Actual behavior
The function fails to compile
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (10 by maintainers)
Top Results From Across the Web
Cannot add mscorlib.dll to Visual Studio project
A reference to 'mscorlib' could not be added. This component is automatically referenced by the project system and cannot be referenced directly ...
Read more >Problems compiling DLLs from MonoDevelop
I have duplicated exactly all the settings in Unity's own Assembly-UnityScript.unityproj and included the exact same references, but when I ...
Read more >Compiler Error CS0731
This error can only occur with improperly formed imported metadata. It cannot occur with only C# source. Example. The following sample generates ...
Read more >C++ project no longer builds in VS2022: could not find ...
Under Project Properties/Advanced/C++/CLI Properties one can find new option: Enable CLR Support for Inividual Files. This item is visible only, ...
Read more >Learn about how to add mscorlib dll reference
Read about how to add mscorlib dll reference, The latest news, videos, and discussion topics about how to add mscorlib dll reference from...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Agreed. The fix will primarily target the .NET package assembly resolver and metadata resolver, but I’ll also make some enhancements to the F# compilation service, including the logging enhancements mentioned above. My goal is to have this (and #890) addressed on the next update, which should happen before the end of the month.
@gshackles will have a fix for this ASAP and see if we can squeeze it in with the next release (which also brings some other F# fixes)
@stefan-akelius the process is a bit less “magical” than what described in the post 😃 For NuGet referenced packages, the behavior you get is similar to what you’d get with .NET Core or Visual Studio, where the appropriate package assemblies are referenced, so there’s no special way to reference those assemblies with a #r (or need to do so). I don’t want to hijack the issue, but I would like to hear more about what you dislike with the current process, as we’re always looking to improve (including exposing the right hooks to enable other flows and better integration with other tools like Packet, which is something that has been discussed) if you could either open an issue with more details or contact me directly at fabio.cavalcante@microsoft.com, that would be great!