Repository navigation
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
- Extend
_WinAppRunSupportActiveto 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 generatedruntimeconfig.json). - In
_WinAppBuildRunArgs, emitrun "<entrypoint>.cs"instead ofrun "<OutputPath>"for that case, reusing the existing#:propertymanifest 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.exeExpected: the gate activates and RunCommand points at the bundled winapp.exe with run "counter.cs".
Notes
- Verified on winapp CLI
0.6.3-dotmorten-perf.38/ package0.6.1, .NET SDK 10. - Related: Run a .NET file-based app with package identity #794 (single-file
winapp run), WindowsAppSDK#6620 (Reactor templates that carry this package reference).
Activity
Support packaged dotnet run for .NET file-based apps (microsoft#874)