Skip to content

System.Reactive reference pulls in all of WPF/SWF when TFM is net7.0-windows10.0.19041.0 or higher #9549

@alexrp

Description

@alexrp

Consider this empty console app project:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net7.0-windows10.0.19041.0</TargetFramework>
    <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Avalonia.Direct2D1" Version="11.0.0-preview4" />
  </ItemGroup>
</Project>

If you do dotnet build and take a peek in bin/Debug/net7.0-windows10.0.19041.0/win10-x64, you'll notice something curious:

-rwxr-xr-x 1 alex 197609  8616056 Oct 19 16:40 PresentationCore.dll
-rwxr-xr-x 1 alex 197609    39088 Oct 19 16:40 PresentationFramework-SystemCore.dll
-rwxr-xr-x 1 alex 197609    34952 Oct 19 16:40 PresentationFramework-SystemData.dll
-rwxr-xr-x 1 alex 197609    34976 Oct 19 16:40 PresentationFramework-SystemDrawing.dll
-rwxr-xr-x 1 alex 197609    34960 Oct 19 16:40 PresentationFramework-SystemXml.dll
-rwxr-xr-x 1 alex 197609    30848 Oct 19 16:40 PresentationFramework-SystemXmlLinq.dll
-rwxr-xr-x 1 alex 197609   456864 Oct 19 16:40 PresentationFramework.Aero.dll
-rwxr-xr-x 1 alex 197609   460936 Oct 19 16:40 PresentationFramework.Aero2.dll
-rwxr-xr-x 1 alex 197609   239776 Oct 19 16:40 PresentationFramework.AeroLite.dll
-rwxr-xr-x 1 alex 197609   272544 Oct 19 16:40 PresentationFramework.Classic.dll
-rwxr-xr-x 1 alex 197609   682120 Oct 19 16:40 PresentationFramework.Luna.dll
-rwxr-xr-x 1 alex 197609   338080 Oct 19 16:40 PresentationFramework.Royale.dll
-rwxr-xr-x 1 alex 197609 16226464 Oct 19 16:40 PresentationFramework.dll
-rwxr-xr-x 1 alex 197609  1234088 Oct  7 05:04 PresentationNative_cor3.dll
-rwxr-xr-x 1 alex 197609  1288352 Oct 19 16:40 PresentationUI.dll
-rwxr-xr-x 1 alex 197609  1628288 Oct 19 16:40 ReachFramework.dll
... snip ...
-rwxr-xr-x 1 alex 197609    16512 Oct 19 03:24 System.Windows.Forms.Design.Editors.dll
-rwxr-xr-x 1 alex 197609  5335168 Oct 19 16:40 System.Windows.Forms.Design.dll
-rwxr-xr-x 1 alex 197609   960672 Oct 19 16:40 System.Windows.Forms.Primitives.dll
-rwxr-xr-x 1 alex 197609 13342848 Oct 19 16:40 System.Windows.Forms.dll
... snip ...
-rwxr-xr-x 1 alex 197609  1958000 Oct 19 06:34 wpfgfx_cor3.dll

Interestingly, changing TFM to net7.0-windows10.0.18362.0 (or lower) does not pull in WPF/SWF. The same is of course true when changing TFM to simply net7.0 or similar.

After some project.assets.json detective work, I figured out why:

https://github.com/dotnet/reactive/blob/85f1eb7c53e27cccdbeee3e0b044916168843fcc/Rx.NET/Source/src/System.Reactive/System.Reactive.csproj#L3-L21

As you can see, System.Reactive is multitargeted for net5.0 and net5.0-windows10.0.19041, with the latter TFM pulling in all of WPF/SWF. 🤦

In an ideal world, the fix here would be for System.Reactive to not assume that a windows TFM necessarily implies UseWPF=true and UseWindowsForms=true. But judging by this upstream issue, it doesn't seem like anything is likely to change here anytime soon, despite this assumption being obviously wrong. I'm not sure what, if anything, can be done on the Avalonia side.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions