Skip to content

ktsu.Sdk.App published for win-x64 from Linux/macOS ships as a console app: the WinExe switch also requires a Windows build host #89

Open

Description

@matt-edmondson

What's wrong

Sdk.App/Sdk.props:11-18 switches the output type to WinExe only when the build host is Windows:

<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Windows')) And $(RuntimeIdentifier.StartsWith('win'))">
  <OutputType>WinExe</OutputType>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Windows')) And '$(RuntimeIdentifier)' == ''">
  <OutputType>WinExe</OutputType>
</PropertyGroup>

Whether an apphost uses the GUI or the console subsystem should depend on the target runtime, not on the machine that built it. Today, dotnet publish -r win-x64 of a ktsu.Sdk.App project on Linux or macOS leaves OutputType=Exe. The resulting .exe uses the console subsystem, so a Windows user who launches the GUI (ImGui) app also gets a console window.

The README says "OutputType=WinExe on Windows (no console window)" (README.md:219) and the host-runtime-only section (README.md:486) says it switches "when the runtime identifier starts with win". Neither mentions that the build host also has to be Windows.

Reproduction

The .NET SDK handles WinExe fine on a non-Windows host. On Linux with .NET 10, cleaning bin/obj between runs:

  • A project importing Sdk.App/Sdk.props, evaluated with -p:RuntimeIdentifier=win-x64, reports OutputType = Exe.
  • dotnet publish -r win-x64 --self-contained false produces an apphost whose PE header says subsystem 3 (console).
  • The same publish with -p:OutputType=WinExe produces subsystem 2 (GUI).

The shared release job runs on windows-latest, so org releases are not affected today. Local and other non-Windows publishes are affected now, and the releases would be too if that job ever moved to Linux.

Suggested fix

  • Key the first condition on the target RID alone: $(RuntimeIdentifier.StartsWith('win')).
  • Keep the host check only for the fallback with no RID, where the host is the target.
  • Add a property-evaluation test (for example next to PlatformSdkResolutionTests) that evaluates the App demo with RuntimeIdentifier=win-x64 and expects WinExe on any host.

Acceptance criteria

  • -r win-x64 produces WinExe on every host.
  • -r linux-x64 and -r osx-arm64 produce Exe on every host.
  • With no RID: WinExe on a Windows host and Exe elsewhere, as today.

Activity

  1. added
    bug
    on Oct 31, 2026
  2. matt-edmondson commented on Oct 31, 2026

    @matt-edmondson
    ContributorAuthor

    Triage

    • Category: Bug
    • Priority: Low. Publishing a ktsu.Sdk.App project for win-x64 from Linux or macOS produces a console-subsystem .exe, so the GUI app opens a console window. Org releases are not affected today because the shared release job runs on windows-latest. Only local or other non-Windows cross-publishes are, and the fix is a one-line condition change. Raise it if the release job ever moves off Windows.
    • Area / suggested owner: Sdk.App/Sdk.props OutputType conditions, plus a property-evaluation test next to PlatformSdkResolutionTests. README lines 219 and 486 should also say what the behaviour is after the fix.
    • Duplicates / in progress: No duplicate found, and no open PR covers it. It touches the same RID/host logic as the KtsuHostRuntimeOnly work in KtsuHostRuntimeOnly resolves the wrong RID under ktsu.Sdk.Linux/macOS/Windows, and does nothing when set in a .csproj as the README shows #63, so check that the two stay consistent.

    Generated by Claude Code

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions