Repository navigation
Add Reactor single-file app template (reactor-singlefile) - #6824
Alexandre Zollinger Chohfi (azchohfi) wants to merge 4 commits into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. |
Adds a "Reactor Single-File App (Experimental)" template to the Microsoft.WindowsAppSDK.WinUI.CSharp.Templates dotnet new pack. It scaffolds the blank Microsoft.UI.Reactor app as a single-file .NET 10 file-based app: one <name>.cs whose #:package / #:property directives replace the .csproj. It runs packaged by default: for `dotnet run <name>.cs`, Microsoft.Windows.SDK.BuildTools.WinApp 0.7.0+ synthesizes an appxmanifest from the directives and launches the app with package identity. The name follows Aspire's aspire-apphost-singlefile, the only first-party dotnet new template for a .NET file-based app. - templates.props: new DotnetNewOnlyProjectTemplate row (reactor.singlefile) and an IncludeGitignore metadata opt-out (default true) so the scaffolded output stays that single file. - WinAppSdk.CSharp.DotnetNewTemplates.csproj: honor IncludeGitignore=false. - reactor-singlefile-app/.template.config: short names reactor-singlefile and winui-reactor-singlefile (winapp new enumerates with `dotnet new list winui`), and hidden from the Visual Studio New Project dialog through ide.host.json unsupportedHosts, since VS cannot open a file-based app. - The file references Microsoft.WindowsAppSDK: with Microsoft.UI.Reactor 0.1.0-preview.16 alone the Windows App SDK defaults to self-contained and the build fails. - README and Test-DotnetNewTemplates.ps1 (new FileBasedApp kind) updated. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
cbbd4f9 to
2b60370
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. |
|
/azp run WindowsAppSDK-Templates-PR |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
/azp run WinAppSDK-Foundation-PR |
|
Azure Pipelines: No pipelines were found matching this branch/path. |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
|
Kyaw Thant (@kythant) It looks like the old ProjectReunion copy of Because it reports under the required |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
There was a bug where both the old and the new WindowsAppSDK-Templates-PR pipelines are running. The new one succeeds, the old one no longer works. I've disabled the pipeline and will close and reopen this PR to see if that reset the CI requirements for merging this in. |
|
Superseded by #6844: the same change, recreated as a fresh commit on current main so it doesn't carry this PR's stale check from the disabled legacy pipeline. |
Summary
Adds a Reactor Single-File App template to the
Microsoft.WindowsAppSDK.WinUI.CSharp.Templatesdotnet newpack, alongside the four Reactor templates from #6620. It scaffolds the blank Reactor (Microsoft.UI.Reactor) app as a single-file .NET 10 file-based app: one.csfile whose#:package/#:propertydirectives replace the.csproj. This is the shape Reactor's getting-started guide documents under One file, no project (microsoft/microsoft-ui-reactor#1283).reactor-singlefile,winui-reactor-singlefile<name>.cs, with no.csproj, assets or manifestThe generated
MyApp.cswith default parameters (the body is the same as thereactorblank app):What changed
dev/Templates/Source/ProjectTemplates/Desktop/CSharp/ReactorSingleFileApp/ProjectTemplate.csis the whole template: the directive header above plus theReactorBlankApp/App.csbody.sourceNamerenames it to<name>.cs, so the assembly name and the synthesized package identity follow the project name.dev/Templates/Dotnet/templates/reactor-singlefile-app/.template.config(template.json,dotnetcli.host.json,ide.host.json,icon.png):Microsoft.WindowsAppSDK.Reactor.CSharp.SingleFileApp; classifications areWindows/WinUI/Desktop/Reactor/SingleFile/Experimental.--dotnet-version(net10.0),--reactor-version(0.1.0-preview.16),--wasdk-version(*, 2.2.0 or later),--windowsSdkBuildToolsWinAppVersion(*, 0.7.0 or later) and--no-restore.dotnet restore <name>.cs, which works on a.csprimary output.dev/Templates/templates.props:reactor.singlefilerow in theDotnetNewOnlyProjectTemplateslot.IncludeGitignoremetadata value (defaulttrue). The new template sets it tofalseso its output stays a single file.dev/Templates/Dotnet/WinAppSdk.CSharp.DotnetNewTemplates.csproj: the pack task skips the shared.gitignorewhenIncludeGitignore=false. Every other template's packed file list is unchanged.dev/Templates/Dotnet/README.md: adds a table row, a "Quickstart a single-file Reactor app" section, and a note on setting theWinAppRun*properties with#:propertyin a single-file app.dev/Templates/Dotnet/Test-DotnetNewTemplates.ps1: a minimalFileBasedAppkind, named after the .NET mechanism. It asserts that the scaffold is exactly<name>.cs, then runsdotnet build <name>.csin the default (packaged) configuration.Design notes
dotnet newtemplate for a .NET file-based app, Aspire'saspire-apphost-singlefile("Aspire Single-File App Host", classificationSingleFile). The descriptions and README keep the official .NET term file-based app, which also separates this fromPublishSingleFile.Microsoft.WindowsAppSDK. With the publishedMicrosoft.UI.Reactor0.1.0-preview.16 alone, the Windows App SDK defaults to self-contained and the build fails withWindowsAppSDKSelfContained requires a supported Windows architecture. The Runtime dependency restored by Restore the Windows App Runtime dependency and document single-file apps microsoft-ui-reactor#1283 hasn't shipped yet. Referencing the metapackage, as the sibling templates do, makes the app framework-dependent and keeps--wasdk-versionmeaningful.dotnet run <file>.cs(Run a .NET file-based app with package identity winappCli#794, Support packaged dotnet run for .NET file-based apps winappCli#874) is new inMicrosoft.Windows.SDK.BuildTools.WinApp0.7.0. With 0.6.1,_WinAppRunSupportActivestaysfalse, sodotnet runstarts the unpackaged exe and the app fails at startup.publisherDn,publisherDisplay,guid9and the Windows SDK BuildTools pin were dropped.Microsoft.Windows.SDK.BuildToolscomes in transitively.#:packagecan't be Debug-only and file-based apps default toPublishAot=true..csproj, there's noapp.manifest, since Reactor sets PerMonitorV2 DPI awareness itself.ide.host.jsonsets"unsupportedHosts": [{ "id": "vs" }], because a file-based app has no project for VS to open. The Aspire single-file template linked above does the same. The .NET CLI ignoreside.host.json, sodotnet newandwinapp neware unaffected.winui-reactor-singlefilealias.winapp newfinds templates withdotnet new list winui, which matches names and short names only. Like the other Reactor templates, this one carries awinui-reactor*alias sowinapp new --listandwinapp new -t reactor-singlefilepick it up.Validation
Local runs used .NET SDK 10.0.401, winapp 0.7.0 and Developer Mode, against the renamed template pack packed from this branch.
dotnet pack:content/reactor.singlefile/holdsProjectTemplate.csplus the four.template.configfiles and nogitignore.txt. Compared with the published0.0.7-alpha, the only content difference is those 5 new entries; the 10 sibling project templates still get theirgitignore.txt.dotnet new list winuianddotnet new list reactorboth listReactor Single-File App (Experimental) reactor-singlefile,winui-reactor-singlefile.dotnet new reactor-singlefile -n MyAppcreates exactlyMyApp\MyApp.csand printsRestoring ...\MyApp\MyApp.cs: ... Restore succeeded..dotnet build MyApp.csin Debug and Release: 0 warnings, 0 errors..csfile; the output goes to%TEMP%\dotnet\runfile\.dotnet run MyApp.csprints✅ Manifest generated for MyApp-53b1794c 1.0.0.0and thenlaunched. The window titled "MyApp" opens, andGetPackageFullNameon the process returnsMyApp-53b1794c_1.0.0.0_x64__gspb8g6x97k2t(AUMID…!App). The package is a dev-mode registration with a dependency onMicrosoft.WindowsAppRuntime.22.5.1.0.#:property WindowsPackageType=Noneadded,dotnet runopens the window, the process has no package identity (APPMODEL_ERROR_NO_PACKAGE), and nothing is registered.winapp run MyApp.cs --detachlaunches the same identity.#:property WinAppRunNoLaunch=trueregisters the app without launching it (checks the README note).dotnet publish MyApp.cs(Native AOT, the default for file-based apps).\artifacts\MyApp\MyApp.exewith 0 warnings.%ProgramFiles(x86)%\Microsoft Visual Studio\Installeris onPATH. Without that, VS 18'svcvarsallfails with'vswhere.exe' is not recognized. This is a toolchain environment issue, not a template one.winapp new --list --template-version installedlistsReactor Single-File App (Experimental) │ reactor-singlefile.winapp new -t reactor-singlefile -n WinappAppscaffoldsWinappApp\WinappApp.cs.--wasdk-version 2.2.0(the documented floor) builds with 0 warnings.Test-DotnetNewTemplates.ps1 -PackagePath <local nupkg> -SkipAppLaunch:All templates validated successfully.41 summary rows areSucceeded: the 6 WinUI and 4 existing Reactor project templates, the newreactor-singlefile(createandbuild, where the build step first asserts the scaffold is a single file), the 7 item templates and the version scenarios. The oneSkippedrow is the default-wildcard build, which the script skips whenever*resolves to a concrete version.winuibuild before any Reactor template ran. That is a network problem on my end, not this change. The passing run used a byte-identical copy of the script whose generatedNuGet.configpoints at a nuget.org proxy. The WindowsAppSDK-Templates-PR pipeline runs the script against the internal feed.CI note
Since the pipeline cutover (#6835),
mainrequiresWinAppSDK-Foundation-PRandWindowsAppSDK-Templates-PR. On40ce46e8:reactor-singlefilealong with the other templates.WASDK_PROJECT_ID: $(System.TeamProjectId)), but 190463 lives in the OS project, so the step fails withNo run of pipeline 190463 on refs/heads/release/main in the last 7 days publishes an artifact named 'WindowsAppSDK-NuGet-And-MSIX'. That step doesn't depend on this PR, which doesn't touch the VSIX templates, and re-running doesn't help. The fix is to disable that definition or remove its PR trigger.Follow-up (outside this repo)
winapp newends withNext: cd "<name>" then winapp run. For a single-file template that fails withManifest file not found, becausewinapp runonly enters single-file mode for an explicit.cspath. The correct command iswinapp run <name>.cs(ordotnet run <name>.cs). That hint needs a fix in winappCli; this template's comments and the README already give the right command.A Microsoft employee must use
/azp runto validate using the PR pipelines.