Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version conflict on Microsoft.Win32.Registry when multitargeting net8.0 and net48 #3856

Closed
flensrocker opened this issue Sep 23, 2024 · 6 comments · Fixed by #3988
Closed

Comments

@flensrocker
Copy link

flensrocker commented Sep 23, 2024

I have some multi target libraries, which contains code for .NET 8 and .NET Standard 2.0.
The .NET Standard target is for some .NET Framework 4.8 applications. For that I use some AspNetCore 2.1 packages (which are still supported for this scenario, as I understand). On .NET 8 I use the FrameworkReference with Microsoft.AspNetCore.App.

My test project is targeting net8.0 and net48 to cover both platforms.

After upgrading MSTest.TestAdapter and MSTest.TestFramework from 3.5.1 to 3.6.0 and Microsoft.NET.Test.Sdk from 17.10.0 to 17.11.1 I see some warnings in the output:

C:\Program Files\dotnet\sdk\8.0.400\Microsoft.Common.CurrentVersion.targets(2412,5): warning MSB3277:
Found conflicts between different versions of "Microsoft.Win32.Registry" that could not be resolved. [C:\src\p\web\Dummy\test\Dummy.UnitTests\Dummy.UnitTests.csproj::TargetFramework=net48]
There was a conflict between "Microsoft.Win32.Registry, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". [C:\src\p\web\Dummy\test\Dummy.UnitTests\Dummy.UnitTests.csproj::TargetFramework=net48]
    "Microsoft.Win32.Registry, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not. [C:\src\p\web\Dummy\test\Dummy.UnitTests\Dummy.UnitTests.csproj::TargetFramework=net48]
    References which depend on "Microsoft.Win32.Registry, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Users\USERNAME\.nuget\packages\microsoft.win32.registry\4.5.0\ref\net461\Microsoft.Win32.Registry.dll]. [C:\src\p\web\Dummy\test\Dummy.UnitTests\Dummy.UnitTests.csproj::TargetFramework=net48]
        C:\Users\USERNAME\.nuget\packages\microsoft.win32.registry\4.5.0\ref\net461\Microsoft.Win32.Registry.dll [C:\src\p\web\Dummy\test\Dummy.UnitTests\Dummy.UnitTests.csproj::TargetFramework=net48]
          Project file item includes which caused reference "C:\Users\USERNAME\.nuget\packages\microsoft.win32.registry\4.5.0\ref\net461\Microsoft.Win32.Registry.dll". [C:\src\p\web\Dummy\test\Dummy.UnitTests\Dummy.UnitTests.csproj::TargetFramework=net48]
            C:\Users\USERNAME\.nuget\packages\microsoft.win32.registry\4.5.0\ref\net461\Microsoft.Win32.Registry.dll [C:\src\p\web\Dummy\test\Dummy.UnitTests\Dummy.UnitTests.csproj::TargetFramework=net48]
    References which depend on or have been unified to "Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" []. [C:\src\p\web\Dummy\test\Dummy.UnitTests\Dummy.UnitTests.csproj::TargetFramework=net48]
        C:\Users\USERNAME\.nuget\packages\microsoft.aspnetcore.dataprotection\2.1.1\lib\netstandard2.0\Microsoft.AspNetCore.DataProtection.dll [C:\src\p\web\Dummy\test\Dummy.UnitTests\Dummy.UnitTests.csproj::TargetFramework=net48]
          Project file item includes which caused reference "C:\Users\USERNAME\.nuget\packages\microsoft.aspnetcore.dataprotection\2.1.1\lib\netstandard2.0\Microsoft.AspNetCore.DataProtection.dll". [C:\src\p\web\Dummy\test\Dummy.UnitTests\Dummy.UnitTests.csproj::TargetFramework=net48]
            C:\Users\USERNAME\.nuget\packages\microsoft.aspnetcore.dataprotection\2.1.1\lib\netstandard2.0\Microsoft.AspNetCore.DataProtection.dll [C:\src\p\web\Dummy\test\Dummy.UnitTests\Dummy.UnitTests.csproj::TargetFramework=net48]
            C:\Users\USERNAME\.nuget\packages\microsoft.aspnetcore.authentication\2.1.2\lib\netstandard2.0\Microsoft.AspNetCore.Authentication.dll [C:\src\p\web\Dummy\test\Dummy.UnitTests\Dummy.UnitTests.csproj::TargetFramework=net48]
        C:\Users\USERNAME\.nuget\packages\microsoft.testing.platform.msbuild\1.4.0\lib\netstandard2.0\Microsoft.Testing.Platform.MSBuild.dll [C:\src\p\web\Dummy\test\Dummy.UnitTests\Dummy.UnitTests.csproj::TargetFramework=net48]
          Project file item includes which caused reference "C:\Users\USERNAME\.nuget\packages\microsoft.testing.platform.msbuild\1.4.0\lib\netstandard2.0\Microsoft.Testing.Platform.MSBuild.dll". [C:\src\p\web\Dummy\test\Dummy.UnitTests\Dummy.UnitTests.csproj::TargetFramework=net48]
            C:\Users\USERNAME\.nuget\packages\microsoft.testing.platform.msbuild\1.4.0\lib\netstandard2.0\Microsoft.Testing.Platform.MSBuild.dll [C:\src\p\web\Dummy\test\Dummy.UnitTests\Dummy.UnitTests.csproj::TargetFramework=net48]

Do you have any suggestions how to deal with this?

I can't disable MSB3277 because sometimes there are "important" conflicts I have to know about.

@nohwnd
Copy link
Member

nohwnd commented Sep 23, 2024

Could you provide a simple repro solution please?

@MarcoRossignoli
Copy link
Contributor

MarcoRossignoli commented Sep 23, 2024

The dep

C:\Users\USERNAME\.nuget\packages\microsoft.testing.platform.msbuild\1.4.0\lib\netstandard2.0\Microsoft.Testing.Platform.MSBuild.dll [C:\src\p\web\Dummy\test\Dummy.UnitTests\Dummy.UnitTests.csproj::TargetFramework=net48]
          Project file item includes which caused reference "C:\Users\USERNAME\.nuget\packages\microsoft.testing.platform.msbuild\1.4.0\lib\netstandard2.0\Microsoft.Testing.Platform.MSBuild.dll". [C:\src\p\web\Dummy\test\Dummy.UnitTests\Dummy.UnitTests.csproj::TargetFramework=net48]
            C:\Users\USERNAME\.nuget\packages\microsoft.testing.platform.msbuild\1.4.0\lib\netstandard2.0\Microsoft.Testing.Platform.MSBuild.dll [C:\src\p\web\Dummy\test\Dummy.UnitTests\Dummy.UnitTests.csproj::TargetFramework=net48]

Is unharmful, the dep is used by the msbuild task and it's not exposed in the dependencies. So it's a false positive(looks to me that it should not appear at all as private build assets)

<PackageReference Include="Microsoft.Win32.Registry" PrivateAssets="All" />

this one

 C:\Users\USERNAME\.nuget\packages\microsoft.aspnetcore.dataprotection\2.1.1\lib\netstandard2.0\Microsoft.AspNetCore.DataProtection.dll [C:\src\p\web\Dummy\test\Dummy.UnitTests\Dummy.UnitTests.csproj::TargetFramework=net48]
          Project file item includes which caused reference "C:\Users\USERNAME\.nuget\packages\microsoft.aspnetcore.dataprotection\2.1.1\lib\netstandard2.0\Microsoft.AspNetCore.DataProtection.dll". [C:\src\p\web\Dummy\test\Dummy.UnitTests\Dummy.UnitTests.csproj::TargetFramework=net48]
            C:\Users\USERNAME\.nuget\packages\microsoft.aspnetcore.dataprotection\2.1.1\lib\netstandard2.0\Microsoft.AspNetCore.DataProtection.dll [C:\src\p\web\Dummy\test\Dummy.UnitTests\Dummy.UnitTests.csproj::TargetFramework=net48]
            C:\Users\USERNAME\.nuget\packages\microsoft.aspnetcore.authentication\2.1.2\lib\netstandard2.0\Microsoft.AspNetCore.Authentication.dll [C:\src\p\web\Dummy\test\Dummy.UnitTests\Dummy.UnitTests.csproj::TargetFramework=net48]

comes from the asp.net runtime so I think that's needed as-is at runtime.

For what I see here we use 5.0.0

<PackageVersion Include="Microsoft.Win32.Registry" Version="5.0.0" />
and in VSTest the 4.0.0 https://github.com/microsoft/vstest/blob/1eb6f23d7739d540ca479b5c031c5fbbb5458a26/src/Microsoft.TestPlatform.CoreUtilities/Microsoft.TestPlatform.CoreUtilities.csproj#L21

For that I use some AspNetCore 2.1 packages (which are still supported for this scenario, as I understand)

@davidfowl can you confirm that asp.net 2.1 is supported?

@flensrocker
Copy link
Author

AspNetCore 2.1 Support:
https://dotnet.microsoft.com/en-us/platform/support/policy/aspnet/2.1-packages

I will try to setup a simple reproduction sample.

The tests are running fine (I should have mentioned that), but the warning in the build output is a bit annoying (we have not a strict "no warning" policy but try to keep them as reduced as possible). So if there's away to disable explicitly this warning it may be ok for me.
But as this should not happen... 🤷

flensrocker added a commit to flensrocker/testfx-issue-3856 that referenced this issue Sep 23, 2024
@flensrocker
Copy link
Author

Reproduction Sample:

https://github.com/flensrocker/testfx-issue-3856

@Evangelink
Copy link
Member

We are waiting for input from MSBuild team

@Evangelink
Copy link
Member

I'll move on with the release of 3.6.2 without that change as we need to re-org and split the code into 2 dlls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment