diff --git a/tools/Templates/templates/WinUiApp-FileBased/.template.config/dotnetcli.host.json b/tools/Templates/templates/WinUiApp-FileBased/.template.config/dotnetcli.host.json new file mode 100644 index 000000000..375341020 --- /dev/null +++ b/tools/Templates/templates/WinUiApp-FileBased/.template.config/dotnetcli.host.json @@ -0,0 +1,32 @@ +{ + "$schema": "http://json.schemastore.org/dotnetcli.host", + "symbolInfo": { + "TargetFrameworkOverride": { + "isHidden": "true", + "longName": "target-framework-override", + "shortName": "" + }, + "Framework": { + "longName": "framework" + }, + "skipRestore": { + "longName": "no-restore", + "shortName": "" + }, + "langVersion": { + "longName": "langVersion", + "shortName": "" + }, + "UseProgramMain": { + "longName": "use-program-main", + "shortName": "" + }, + "NativeAot": { + "longName": "aot", + "shortName": "" + } + }, + "usageExamples": [ + "" + ] +} diff --git a/tools/Templates/templates/WinUiApp-FileBased/.template.config/template.json b/tools/Templates/templates/WinUiApp-FileBased/.template.config/template.json new file mode 100644 index 000000000..c23036848 --- /dev/null +++ b/tools/Templates/templates/WinUiApp-FileBased/.template.config/template.json @@ -0,0 +1,102 @@ +{ + "$schema": "http://json.schemastore.org/template", + "author": "Microsoft", + "classifications": [ "Windows", "WinUI" ], + "identity": "Microsoft.UI.Reactor.FileBased", + "groupIdentity": "Microsoft.UI.Reactor.FileBased", + "name": "Microsoft WinUI Reactor File-Based App", + "description": "A Windows WinUI Application using Reactor with file-based structure", + "shortName": "reactorapp-filebased", + "tags": { + "language": "C#", + "type": "project" + }, + "sourceName": "Company.ReactorApp1", + "preferNameDirectory": true, + "symbols": { + "TargetFrameworkOverride": { + "type": "parameter", + "description": "Overrides the target framework", + "replaces": "TargetFrameworkOverride", + "datatype": "string", + "defaultValue": "", + "displayName": "Target framework override" + }, + "Framework": { + "type": "parameter", + "description": "The target framework for the project.", + "datatype": "choice", + "choices": [ + { + "choice": "net10.0", + "description": "Target net10.0", + "displayName": ".NET 10.0" + } + ], + "replaces": "net10.0", + "defaultValue": "net10.0", + "displayName": "Framework" + }, + "skipRestore": { + "type": "parameter", + "datatype": "bool", + "description": "If specified, skips the automatic restore of the project on create.", + "defaultValue": "false", + "displayName": "Skip restore" + }, + "UseProgramMain": { + "type": "parameter", + "datatype": "bool", + "defaultValue": "false", + "description": "Whether to generate an explicit Program class and Main method instead of top-level statements.", + "displayName": "Do not use _top-level statements" + }, + "NativeAot" : { + "type": "parameter", + "datatype": "bool", + "defaultValue": "false", + "displayName": "Enable _native AOT publish", + "description": "Whether to enable the project for publishing as native AOT." + }, + "HostIdentifier": { + "type": "bind", + "binding": "HostIdentifier" + }, + "csharpFeature_TopLevelProgram": { + "type": "computed", + "value": "UseProgramMain != \"true\"" + }, + "MSUIReactorVersion": { + "type": "parameter", + "dataType": "string", + "replaces": "MS_UI_REACTOR_VERSION", + "defaultValue": "MS_UI_REACTOR_VERSION_VALUE" + }, + }, + "primaryOutputs": [ + { + "path": "App.cs" + }, + ], + "defaultName": "WinUIApp1", + "postActions": [ + { + "id": "restore", + "condition": "(!skipRestore)", + "description": "Restore NuGet packages required by this project.", + "args": { + "executable": "dotnet.exe", + "args": "restore App.cs", + "redirectStandardOutput": false, + "redirectStandardError": false + }, + "manualInstructions": [ + { + "text": "Run 'dotnet restore'" + } + ], + "actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2", + "continueOnError": true + } + ] +} diff --git a/tools/Templates/templates/WinUiApp-FileBased/App.cs b/tools/Templates/templates/WinUiApp-FileBased/App.cs new file mode 100644 index 000000000..144c28491 --- /dev/null +++ b/tools/Templates/templates/WinUiApp-FileBased/App.cs @@ -0,0 +1,43 @@ +using System; +using Microsoft.UI.Reactor; +using Microsoft.UI.Reactor.Core; // BackdropKind +using Microsoft.UI.Reactor.Layout; // FlexDirection, FlexJustify, FlexAlign +using Microsoft.UI.Xaml; // Thickness, HorizontalAlignment, VerticalAlignment +using Microsoft.UI.Xaml.Controls; // Orientation, InfoBarSeverity, etc. +using static Microsoft.UI.Reactor.Factories; + +#if (csharpFeature_TopLevelProgram) +ReactorApp.Run("Company.ReactorApp1", width: 900, height: 600); + +#else +namespace Company.ReactorApp1; + +class Program +{ + static void Main(string[] args) + { + ReactorApp.Run("Company.ReactorApp1", width: 900, height: 600); + } +} + +#endif +class App : Component +{ + public override Element Render() + { + var (name, setName) = UseState("World"); + + var titleBar = TitleBar("Company.ReactorApp1").Flex(shrink: 0); + + var body = Border( + FlexColumn( + Heading($"Hello, {name}!"), + TextBox(name, setName, placeholderText: "Your name") + .AutomationName("NameInput") + ) with { RowGap = 16 } + ).Padding(24).Flex(grow: 1, basis: 0); + + return FlexColumn(titleBar, body) + .Backdrop(BackdropKind.Mica); + } +} diff --git a/tools/Templates/templates/WinUiApp-FileBased/Directory.Build.props b/tools/Templates/templates/WinUiApp-FileBased/Directory.Build.props new file mode 100644 index 000000000..291b5e3c4 --- /dev/null +++ b/tools/Templates/templates/WinUiApp-FileBased/Directory.Build.props @@ -0,0 +1,45 @@ + + + WinExe + net10.0-windows10.0.22621.0 + TargetFrameworkOverride-windows10.0.22621.0 + + x64;ARM64;X86 + true + None + + true + 10.0.17763.0 + 10.0.17763.0 + enable + + $(NETCoreSdkPortableRuntimeIdentifier) + + true + true + + + diff --git a/tools/Templates/templates/WinUiApp-FileBased/Directory.Packages.props b/tools/Templates/templates/WinUiApp-FileBased/Directory.Packages.props new file mode 100644 index 000000000..06fc13432 --- /dev/null +++ b/tools/Templates/templates/WinUiApp-FileBased/Directory.Packages.props @@ -0,0 +1,22 @@ + + + + + + + + + + + + diff --git a/tools/Templates/templates/WinUiApp-FileBased/Properties/launchSettings.json b/tools/Templates/templates/WinUiApp-FileBased/Properties/launchSettings.json new file mode 100644 index 000000000..6cc2775bc --- /dev/null +++ b/tools/Templates/templates/WinUiApp-FileBased/Properties/launchSettings.json @@ -0,0 +1,20 @@ +{ + "//": "Default F5 / `dotnet run` profile for the scaffolded Reactor app. The devtools", + "//": "profile pairs --devtools with the Debug-only `Microsoft.UI.Reactor.Devtools` package +", + "//": "Reactor.DevtoolsSupport host config option (see Directory.Packages.props).", + "//": "Release builds exclude the devtools package, so the default profile does not pass", + "//": "--devtools. The Reactor Visual Studio embedded-preview extension (spec 056) launches", + "//": "with its own argv (`--devtools run --embed --embed-host-pid `) and does not", + "//": "consult this file.", + "profiles": { + "Company.ReactorApp1": { + "commandName": "Project", + "nativeDebugging": false + }, + "Company.ReactorApp1 Devtools": { + "commandName": "Project", + "commandLineArgs": "--devtools", + "nativeDebugging": false + } + } +}