Remove dependency on System.ValueTuple NuGet package when targeting .Net 4.7
vlardn opened this issue ยท 9 comments
After switching project from .NET 4.6.1 to .NET 4.7.2 the following errors appear:
Severity Code Description Project File Line Suppression State
Error CS8356 Predefined type 'System.ValueTuple`2' is declared in multiple referenced assemblies: 'System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' and 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' ...
The possible reason is that System.ValueTuple is incompatible with .Net Framework 4.7 (because it's already built in to 4.7).
Somehow I knew that dependency was trouble. Iโm going to remove it completely ๐
Actually there is a workaround for now: use a .NET 4.7 build of System.ValueTuple that seems just contains references to value tuple types from mscorlib. There are 2 ways how to do it:
- . Change to "net47" in HintPath like this:
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
- Or use "Update-Package -Reinstall" to update all such packages. I think this is preferable method after switching to another .NET framework version but it usually produces much more changes.
@vlardn thank you :D Update-Package -Reinstall basically saved me a day of work to update my 100+ projects ๐
Iโm going to remove it completely ๐
Anyway that's the best solution, there is no need in the library "System.ValueTuple" at all if one is targeting .NET47 or higher.
The last version I'm able to use is 5.1.8.
The version 5.1.9 introduced dependency to ValueType and I no longer can use it.
Could you reopen the issue and remove the dependency?
I have this for xxxx.dll that references LightInject:
Warning MSB3258: The primary reference "xxxx.dll" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" which has a higher version "4.0.3.0" than the version "4.0.2.0" in the current target framework.
Fixed by #532
@andrzejmartyna2 Version 6.3.4 has removed this dependency ๐
I'm really appreciate it!
Already verified and works. Thanks!!