waf / CSharpRepl

A command line C# REPL with syntax highlighting – explore the language, libraries and nuget packages interactively.
https://fuqua.io/CSharpRepl/
Mozilla Public License 2.0
2.93k stars 113 forks source link

Adding a project reference (#r) to project with multiple target frameworks fails #186

Closed tparviainen closed 2 years ago

tparviainen commented 2 years ago

Version

C# REPL 0.4.0

What happened?

Create an empty netstandard2.0 project using next command:

dotnet new classlib -f netstandard2.0

Adding a reference (#r) to that project succeeds. Then add netstandard2.1 also to the target framework i.e. change csproj file to contain next line:

<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>

Restart REPL and add a reference (#r) to the project gives next output:

> #r "C:\Dev\Temp\ClassLib1\ClassLib1.csproj"
Building C:\Dev\Temp\ClassLib1\ClassLib1.csproj
MSBuild version 17.3.2+561848881 for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
  ClassLib1 -> C:\Dev\Temp\ClassLib1\bin\Debug\netstandard2.1\ClassLib1.dll
  ClassLib1 -> C:\Dev\Temp\ClassLib1\bin\Debug\netstandard2.0\ClassLib1.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.95
An element with the same key but a different value already exists. Key: 'ClassLib1'

Last row in a console it is using red color. The end result is that the project reference is not added to C# repl session.

waf commented 2 years ago

Thanks for raising this. I've opened #188 which I believe should fix this issue (as well as some other issues around project/solution loading).

waf commented 2 years ago

This has been resolved in the latest release of csharprepl (v0.5.0)! Please give it a try and let me know if you run into any issues. Thanks for reporting it.