C#C
C#3w ago
56 replies
KazWolfe

Forcing MSBuild to use non -windows version of a dependency

Hi all - I'm working on a plugin loader and want to add https://www.nuget.org/packages/StreamJsonRpc/ to my library. However, I'm running into a quirk: this is causing build warnings in some plugins. I've traced this back to the fact that because the plugin loader is targeted to -windows, a child of the above dependency will set <UseWPF>true</UseWPF>. While this doesn't matter for the plugin loaders themselves, the other maintainers of the project would prefer not to reference WPF, especially when it's not necessary for any API surface (and since we support Wine-based environments).

As this is probably an X/Y problem, the error in question is as follows:
0>Microsoft.Common.CurrentVersion.targets(2437,5): Warning MSB3277 : Found conflicts between different versions of "WindowsBase" that could not be resolved.
There was a conflict between "WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" and "WindowsBase, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35".
    "WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" was chosen because it was primary and "WindowsBase, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" was not.
    References which depend on "WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" [C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\10.0.0\ref\net10.0\WindowsBase.dll].
        C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\10.0.0\ref\net10.0\WindowsBase.dll
          Project file item includes which caused reference "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\10.0.0\ref\net10.0\WindowsBase.dll".
            C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\10.0.0\ref/net10.0/WindowsBase.dll
    References which depend on or have been unified to "WindowsBase, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" [].
        C:\Users\Kaz\AppData\Roaming\XIVLauncher\addon\Hooks\dev\Microsoft.VisualStudio.Threading.dll
          Project file item includes which caused reference "C:\Users\Kaz\AppData\Roaming\XIVLauncher\addon\Hooks\dev\Microsoft.VisualStudio.Threading.dll".
            Dalamud


This doesn't block any builds, but it does cause a considerable amount of dev confusion - and WPF itself is simply unnecessary for our use case.

Short of forking vs-streamjsonrpc to tear out all the WPF code (which itself comes from Microsoft.VisualStudio.Threading.Only), is there any way I can force MSBuild to not use the -windows targeted version of this lib?
A cross-platform .NETStandard library that implements the JSON-RPC wire protocol and can use System.IO.Stream, System.IO.Pipelines or WebSocket so you can use it with any transport.
StreamJsonRpc 2.22.23
Was this page helpful?