Sdk: Multiple library redirect warnings with .NET 4.7.1 and new SDK project format

Created on 31 Oct 2017  路  14Comments  路  Source: dotnet/sdk

_From @Tornhoof on October 19, 2017 7:56_

Upgrading to .NET 4.7.1 with the new SDK format results in multiple library redirect warnings for system libraries (e.g. System.IO). Targeting .NET 4.7 does not have this problem.

There was a conflict between "System.Runtime, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
     "System.Runtime, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
     References which depend on "System.Runtime, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.runtime\4.3.0\ref\net462\System.Runtime.dll].
         C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.runtime\4.3.0\ref\net462\System.Runtime.dll
           Project file item includes which caused reference "C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.runtime\4.3.0\ref\net462\System.Runtime.dll".
             C:\Program Files\dotnet\sdk\NuGetFallbackFolder\system.runtime\4.3.0\ref\net462\System.Runtime.dll
     References which depend on "System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.1\Facades\System.Runtime.dll].
         C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.codeanalysis.common\2.3.1\lib\netstandard1.3\Microsoft.CodeAnalysis.dll
           Project file item includes which caused reference "C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.codeanalysis.common\2.3.1\lib\netstandard1.3\Microsoft.CodeAnalysis.dll".
             C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.razor\2.0.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.dll
             C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.codeanalysis.common\2.3.1\lib\netstandard1.3\Microsoft.CodeAnalysis.dll
             C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.codeanalysis.csharp\2.3.1\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll
             C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.razorpages\2.0.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.RazorPages.dll
             C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.razor.extensions\2.0.0\lib\net46\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll
             C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc\2.0.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.dll
             C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.taghelpers\2.0.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.TagHelpers.dll
             C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.localization\2.0.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Localization.dll
             C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.codeanalysis.razor\2.0.0\lib\net46\Microsoft.CodeAnalysis.Razor.dll
         C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.codeanalysis.csharp\2.3.1\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll
           Project file item includes which caused reference "C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.codeanalysis.csharp\2.3.1\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll".
             C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.razor\2.0.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.dll
             C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.codeanalysis.csharp\2.3.1\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll
             C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.razorpages\2.0.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.RazorPages.dll
             C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.razor.extensions\2.0.0\lib\net46\Microsoft.AspNetCore.Mvc.Razor.Extensions.dll
             C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc\2.0.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.dll
             C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.taghelpers\2.0.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.TagHelpers.dll
             C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.localization\2.0.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Localization.dll
             C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.codeanalysis.razor\2.0.0\lib\net46\Microsoft.CodeAnalysis.Razor.dll

There are warnings for the following libraries

System.ValueTuple,
System.Runtime,
System.IO,
System.Reflection,
System.Security.Cryptography,
System.Linq,
System.Runtime.Extensions,
System.Runtime.InteropServices,
System.IO.FileSystem,
System.IO.FileSystem.Primitives,
System.Xml.ReaderWriter,
System.Security.Cryptography.Primitives,
System.Linq.Expressions,

Steps to reproduce

  1. Create a new solution
  2. Create a web project targeting ASP.NET targeting net471
  3. Create a lib project with XUnit 2.3 and targeting net471 with new SDK project format
  4. Enable the auto binding redirect settings (apparently makes no difference)
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
  1. Add a few unit tests

    Expected result

  2. No build warnings

    Actual result

  3. Redirect warnings

RedirectWarnings.zip

_Copied from original issue: dotnet/project-system#2905_

Most helpful comment

I can't even believe this is still going on. It's been YEARS of such monkey business, and count this as the umpteenth time I've torched a whole solution trying to update big full .NET solutions to get in some harmony with the new .NET world. (Which by the way, it really does become all or nothing; to go to net 4.7.1, means projects above those must be 4.7.1 or higher, but if you have underlying projects at a lesser level, you get even more dependency nuget dll nightmares, and finally just update the whole stack of dependencies, which fixes many of the problems, until you find there are still outstanding ones). Many of us would love nothing more than to simply convert to net core, but where that's impossible. But at least what we can do then is everything possible to update to the latest full framework version to finally get in some harmony with the new netstandard and newer ways of doing things, if not even to share in the new csproj type, and get as many dependency libraries that can convert to net core / standard to do that (you can't do that if referencing them makes things go bonkers!). I just went thru this in November of 2017, and again had to give up and restore solution and many dependency projects back from backup, because of so many million problems (I could reference the github threads on this but don't care to find it), that .NET 4.7.1 was supposed to fix. But here we go again. And if you need proof that this has been going on for YEARS, see this article I posted just over 3 years ago, that's right, THREE years ago:
https://stackoverflow.com/questions/28097981/can-the-new-asp-net-5-asp-net-mvc-6-project-type-target-regular-net
And yet that promise is still encumbered by this madness. I have all of the problems above popping up, and no solutions were given, and yet it's March of 2018 now. It's simply maddening.

All 14 comments

_From @jackowild on October 19, 2017 10:55_

I am also having this problem. It can be reproduced even easier by simply creating a new "ASP.NET Core Web Application" project targeting net471, and then building it without making any changes.

@dsplaisted Does this look familiar?

Also tagging @terrajobst

_From @bburman on October 25, 2017 14:21_

I'm experiencing this as well. Any recommendations or workarounds for this short of going back to .NET Framework 4.7 or suppressing the warnings? I can add assembly redirects in a config file, but it doesn't get rid of the compiler warnings.

_From @Tornhoof on October 25, 2017 14:55_

I don't know any other workaround for it. I went back to 4.7 after the numerous errors with 4.7.1.

Also experiencing this problem. Any workaround would be greatly appreciated, since it currently prevents us from migrating to .NET 4.7.1.

@tornhoof @jackowild @bburman @alphaleonis Can you try this with Visual Studio 2017 Update 5 Preview 2 or later? I think this has already been fixed. Let us know if that fixes the issue or not for you.

Thanks!

Yeah, my test project builds without those warnings in VS 15.5 Preview 2.
Thanks

@dsplaisted I tested this in VS 2017 15.5 Preview 2 and indeed it seems the problem has been solved here.

@dsplaisted Works like a champ in VS 2017 Update 5 Preview 2! Thanks much!

Closing as this was fixed for 15.5 Preview2.

So please confirm, this is up to Visual Studio 2017 ?
Because I have:
dotnet new webapi
edit .csproj and put net471
dotnet build

same warning MSB3277 in output.
How would VS update help on this?

Is it safe to ignore this warning?

I can't even believe this is still going on. It's been YEARS of such monkey business, and count this as the umpteenth time I've torched a whole solution trying to update big full .NET solutions to get in some harmony with the new .NET world. (Which by the way, it really does become all or nothing; to go to net 4.7.1, means projects above those must be 4.7.1 or higher, but if you have underlying projects at a lesser level, you get even more dependency nuget dll nightmares, and finally just update the whole stack of dependencies, which fixes many of the problems, until you find there are still outstanding ones). Many of us would love nothing more than to simply convert to net core, but where that's impossible. But at least what we can do then is everything possible to update to the latest full framework version to finally get in some harmony with the new netstandard and newer ways of doing things, if not even to share in the new csproj type, and get as many dependency libraries that can convert to net core / standard to do that (you can't do that if referencing them makes things go bonkers!). I just went thru this in November of 2017, and again had to give up and restore solution and many dependency projects back from backup, because of so many million problems (I could reference the github threads on this but don't care to find it), that .NET 4.7.1 was supposed to fix. But here we go again. And if you need proof that this has been going on for YEARS, see this article I posted just over 3 years ago, that's right, THREE years ago:
https://stackoverflow.com/questions/28097981/can-the-new-asp-net-5-asp-net-mvc-6-project-type-target-regular-net
And yet that promise is still encumbered by this madness. I have all of the problems above popping up, and no solutions were given, and yet it's March of 2018 now. It's simply maddening.

agreed, a failure, to say the least.

Was this page helpful?
0 / 5 - 0 ratings