0 votes
ago by (220 points)

An unexpected build error was observed when an existing app (targeting .NET 11) upgraded Rebex packages from 8.0.9797 to 8.0.9820.

Steps to reproduce

Create repro.csproj with the following content:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net11.0-windows</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Rebex.Terminal.Control" Version="8.0.9820" />
  </ItemGroup>
</Project>

Create Program.cs next to repro.csproj with the following content:

using Rebex.TerminalEmulation;
ITerminal _ = new TerminalControl();

Using .NET SDK 11.0.100, run dotnet build:

repro net11.0-windows failed with 2 error(s)
C:\repro\Program.cs(2,15): error CS7069: Reference to type 'afadl' claims it is defined in 'Rebex.Terminal', but it could not be found
C:\repro\Program.cs(2,15): error CS7069: Reference to type 'uhqmz' claims it is defined in 'Rebex.Terminal', but it could not be found

Downgrading Rebex.Terminal.Control package in repro.csproj to the previous version 8.0.9797 makes the project build as expected. Is this a regression in the latest version?

1 Answer

0 votes
ago by (152k points)

Thanks for bringing this to our attention! It looks like an unfortunate side effect of the addition of .NET 11 assemblies to v8.0.9820 of Rebex NuGet packages.

For .NET 11, we intended to indicate lack of Windows 7 support by using the appropriate TFMs in Rebex.Terminal.Control package:

<group targetFramework="net11.0-windows10.0">
  <frameworkReference name="Microsoft.WindowsDesktop.App.WindowsForms" />
</group>
<group targetFramework="net10.0-windows7.0">
  <frameworkReference name="Microsoft.WindowsDesktop.App.WindowsForms" /
</group>
...

While Rebex.Terminal and other UI-less packages use these, as expected:

<group targetFramework="net11.0">
  <dependency id="Rebex.Common" version="[8.0.9820]" exclude="Build,Analyzers" />
</group>
<group targetFramework="net10.0">
  <dependency id="Rebex.Common" version="[8.0.9820]" exclude="Build,Analyzers" />
</group>

Unfortunately, as you just found out, this breaks if your TargetFramework is net11.0-windows. Apparently, this causes the compiler to use Rebex.Terminal.Control.dll targeting .NET 10, together with Rebex.Terminal.dll targeting .NET 10. But those two Rebex assemblies are not in fact compatible, causing a compile error.

Updating TargetFramework in your repro.csproj to net11.0-windows10.0 should fix the issue without having to downgrade to v8.0.9797.

In the next release, I guess we'll have to change the TFM to net11.0-windows7.0 in order to prevent the undesirable behavior, although this clearly is not a great solution either.

ago by (220 points)
I understand the situation now, thank you for explaining it. That's rather unfortunate.

It would perhaps be valuable to consider a hotfix release that restores compatibility with `net11.0-windows7.0`, if possible. As far as I can tell WinForms in .NET 11 still targets that level.

ref. https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416#tfm-target-platforms

> If the TFM has a target platform, the .NET SDK injects a `SupportedOSPlatform` attribute with the targeted platform name in the *AssemblyInfo.cs* file [...] For example, if the TFM is `net5.0-windows10.0.19041`, the SDK injects the `[assembly: System.Runtime.Versioning.SupportedOSPlatform("windows10.0.19041")]` attribute into the *AssemblyInfo.cs* file

Examining `%ProgramFiles%\dotnet\shared\Microsoft.WindowsDesktop.App\11.0.0\System.Windows.Forms.dll` with ILSpy finds these attributes are embedded:

    [assembly: TargetFramework(".NETCoreApp,Version=v11.0", FrameworkDisplayName = ".NET 11.0")]
    [assembly: SupportedOSPlatform("windows6.1")]

I believe this means that WinForms still targets `net11.0-windows7.0` on .NET 11 (NT 6.1 was the internal version code for Windows 7.)

It would therefore be very helpful if hotfix packages could be published using a compatible target framework for .NET 11.
ago by (220 points)
> Updating TargetFramework in your repro.csproj to net11.0-windows10.0 should fix the issue without having to downgrade to v8.0.9797.

It looks like the `net11.0-windows10.0` syntax may be accepted by NuGet, but isn't accepted by the SDK/compiler. When `repro.csproj` is retargetted to that TFM the result is:

  repro net11.0-windows10.0 failed with 1 error(s)
    C:\Program Files\dotnet\sdk\11.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(283,5): error NETSDK1140:
      10.0.0.0 is not a valid TargetPlatformVersion for Windows. Valid versions include:
      10.0.26100.1
      10.0.22621.1
      10.0.22000.1
      10.0.20348.1
      10.0.19041.1
      10.0.18362.1
      10.0.17763.1
      10.0.26100.0
      10.0.22621.0
      10.0.22000.0
      10.0.20348.0
      10.0.19041.0
      10.0.18362.0
      10.0.17763.0
      10.0.26100.0
      10.0.22621.0
      10.0.22000.0
      10.0.20348.0
      10.0.19041.0
      10.0.18362.0
      10.0.17763.0
      10.0.26100.0
      10.0.22621.0
      10.0.22000.0
      10.0.20348.0
      10.0.19041.0
      10.0.18362.0
      10.0.17763.0
      10.0.22000.0
      10.0.20348.0
      10.0.19041.0
      10.0.18362.0
      10.0.17763.0
      8.0
      7.0

It appears required to choose a *specific build number* for Windows 10.

But even choosing the oldest version listed (`windows-10.0.17763.0`) would still bump the app's minimum OS requirement above what WinForms supports when targeting .NET 11. It would be better if Rebex packages would not require this compromise.
ago by (152k points)
Thanks for the additional research. It looks like you are right, and changing the TFM to "net11.0-windows7.0" seems to be the best solution. We'll publish a hotfix package within days!
ago by (220 points)
That's good to hear and much appreciated -- thank you!
...