dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.74k stars 1.07k forks source link

WindowsBase version conflict between Microsoft.WindowsDesktop.App and Microsoft.NETCore.App #41909

Open gvdkamp-tw opened 4 months ago

gvdkamp-tw commented 4 months ago

We're getting an MSB3277 Warning for a conflict between WindowsBase 4.0.0.0, coming from an implicit Microsoft.NETCore.App Framework reference and Version 8.0.0.0 which is coming from a Microsoft.WindowsDesktop App.

We have assemblies with Windows-Forms and we have assemblies without UI components which should do not need a framework reference to Microsoft.WindowsDesktop.App. The default reference to Microsoft.NETCore.App should be enough. But compiling these assemblies gives us the MSB3277 Warning stating that the older version 4.0.0.0 from NETCore.App is used instead of 8.0.0.0

Searching the internet i find suggestions where other developers enable "UseWPF" in their projects (to force a framework reference to Microsoft.WindowsDesktop.App) and therefore explicitly referencing version 8.0.0.0 in the project. This is not a solution. Certainly not for us, because we still use Windows-Forms and not WPF.

Another Hack to get around the problem seems to be adding an explicit framework reference to Microsoft.WindowsDesktop.App and thereby referencing version 8.0.0.0 of WindowsBase. This also gets rid of the warning and our code works with this hack. But this can't be the real solution for the problem in the SDK.

Is there a better way or should we wait for the version incompatibility gets fixed in the SDK?

marcpopMSFT commented 4 months ago

See the comment here: https://github.com/dotnet/sdk/issues/30953#issuecomment-1451061365 @ericstj I don't believe anything has changed here but how should a customer avoid the version conflict when building?

ericstj commented 4 months ago

we have assemblies without UI components which should do not need a framework reference to Microsoft.WindowsDesktop.App

It sounds to me like you're trying to consume a library built for WPF or Winforms in a project that doesn't have a framework reference WindowsDekstop.App. The only way you'd get a reference to WindowsBase is if you were actually using types from it. The assembly in NETCore.App has no types -- so you cannot actually have a reference to it when building against NETCore.App. If you compile assembly with a framework reference you must consume it in projects with that framework reference.

I'd recommend you inspect the build of your project you expect

should do not need a framework reference to Microsoft.WindowsDesktop.App

To find out why it has a reference to WindowsBase - that reference is what's causing this.

unseensenpai commented 1 month ago

Still have this issue on v8.0.402 SDK.

Any progress should we know?

truonghoaitcm commented 1 month ago

So many issues from VS2022 and .NET 6 .NET 8. However, Microsoft skips those!