Errors when using different versions of the same package with type providers in the same solution
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
1. Create a solution with 2 projects targeting net5 (and MSBuild from net5 sdk)
2. Add `FSharp.Text.RegexProvider v2.1.0/2.0.2` to each project
**Expected:**
No errors
**Actual:**
The first open project is successfully type-checked, the second project is open with the message _"The type 'Regex' is not defined"_
But both projects are built successfully.
Reproduced in Rider (FCS netstandard 2.0, with type providers hosted in .NET 5.0.3 runtime)
and VS Code Ionide 5.3.2


When FCS tries to instantiate the type provider for the second project, [ this code ](https://github.com/dotnet/fsharp/blob/main/src/fsharp/utils/CompilerLocationUtils.fs#L292) fails with _"Assembly with same name is already loaded"_
Repro:
[net5repro.zip](https://github.com/dotnet/fsharp/files/6017692/net5repro.zip)
Contributor guide
Assessment
This issue has not been assessed yet.