Skip to content

Support packaged dotnet run for .NET file-based apps (.cs) via the BuildTools.WinApp targets #871

Closed

Description

Summary

winapp run counter.cs (single-file mode, #794) works well. But when a file-based app references Microsoft.Windows.SDK.BuildTools.WinApp, plain dotnet run counter.cs does not get the packaged-launch redirect that project-based apps already get — it launches the raw unpackaged .exe instead.

Everything needed is already in the package. Exactly one condition in the master gate blocks it.

Why this is worth doing

The Windows App SDK reactor templates (WindowsAppSDK#6620) already reference Microsoft.Windows.SDK.BuildTools.WinApp, and the package bundles the CLI (tools/win-x64/winapp.exe, tools/win-arm64/winapp.exe). So a user who scaffolds from a template — or who just adds one #:package line — would get packaged dotnet run for a single .cs file with no global tool install and no manifest authoring.

That makes "one C# file → a real app with package identity" a two-line story, which is a very compelling on-ramp. We're writing the Reactor getting-started guide around this shape right now.

What already works

Verified locally against Microsoft.Windows.SDK.BuildTools.WinApp 0.6.1 with a .NET 10 file-based Reactor app:

Status
buildTransitive props/targets are imported for a #:package file-based app ✅ confirmed in the generated obj/*.nuget.g.props
WinAppCliPath resolves to the bundled CLI from inside a .cs app ✅ …\0.6.1\tools\win-x64\winapp.exe
The package already overrides dotnet run for packaged projects — _WinAppPrepareRunArguments runs BeforeTargets="ComputeRunArguments" and sets RunCommand=$(WinAppCliPath) / RunArguments=run "<OutputPath>" --manifest … ✅
winapp run counter.cs itself ✅ works today

What blocks it

_WinAppRunSupportActive in buildTransitive/Microsoft.Windows.SDK.BuildTools.WinApp.targets:

<_WinAppRunSupportActive Condition="
    '$(EnableWinAppRunSupport)' == 'true'
    And '$(WindowsPackageType)' != 'None'
    And '$(OutputType)' != 'Library'
    And '$(_WinAppEffectiveTargetPlatformIdentifier)' == 'windows'
    And '$(WinAppManifestPath)' != ''
    And Exists('$(WinAppManifestPath)')">true</_WinAppRunSupportActive>

A file-based app has no authored manifest by design — inferring one from #:property directives is exactly what single-file mode already implements in SingleFileManifestPlanner. So WinAppManifestPath is empty and the gate goes inert.

Measured on a file-based Reactor app (dotnet build counter.cs --no-restore -getProperty:…):

WinAppCliPath           = C:\...\microsoft.windows.sdk.buildtools.winapp\0.6.1\...\tools\win-x64\winapp.exe
WinAppManifestPath      = ""
_WinAppRunSupportActive = false
RunCommand              = C:\...\runfile\counter-<hash>\bin\debug\counter.exe      <-- not redirected

Proposed change

  1. Extend _WinAppRunSupportActive to also activate for a .NET 10 file-based app when no authored manifest exists (detectable via the SDK's file-based-app properties, e.g. EntryPointFilePath, which is already present in the generated runtimeconfig.json).
  2. In _WinAppBuildRunArgs, emit run "<entrypoint>.cs" instead of run "<OutputPath>" for that case, reusing the existing #:property manifest inference.

Resulting UX

The header property becomes the mode switch, symmetrically:

Header dotnet run counter.cs
#:property WindowsPackageType=None unpackaged (works today)
omit it, plus #:package Microsoft.Windows.SDK.BuildTools.WinApp packaged, with identity (this request)

Note the existing WindowsPackageType != 'None' clause already gives the correct discrimination for free — no new opt-in property needed.

Repro

// counter.cs
#:package Microsoft.UI.Reactor@0.1.0-preview.11
#:package Microsoft.Windows.SDK.BuildTools.WinApp@0.6.1
#:property OutputType=WinExe
#:property TargetFramework=net10.0-windows10.0.22621.0
#:property UseWinUI=true
#:property Platform=x64

using Microsoft.UI.Reactor;
using Microsoft.UI.Reactor.Core;
using static Microsoft.UI.Reactor.Factories;

ReactorApp.Run<Counter>("Counter");

class Counter : Component
{
    public override Element Render() => TextBlock("hi");
}
dotnet build counter.cs --no-restore -getProperty:_WinAppRunSupportActive -getProperty:RunCommand
# _WinAppRunSupportActive = false ; RunCommand = the raw counter.exe

Expected: the gate activates and RunCommand points at the bundled winapp.exe with run "counter.cs".

Notes

Activity

  1. added a commit that references this issue on Sep 20, 2026
    fb52df2
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions