dotnet / dotnet/fsharp

Errors when using different versions of the same package with type providers in the same solution

Open
#11,135 4 comments 1 reaction 0 assignees View on GitHub
Bug
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

![image](https://user-images.githubusercontent.com/26364714/108624944-282ed000-7459-11eb-9ba9-aa4213809b55.png)
![image](https://user-images.githubusercontent.com/26364714/108624954-3381fb80-7459-11eb-97a0-74fdf8ae9377.png)

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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.