Skip to content

Commit

Permalink
invoke mcs-editorconfig from mcs-winui3-app, set main window size on …
Browse files Browse the repository at this point in the history
…windows
  • Loading branch information
VincentH-Net committed Feb 28, 2023
1 parent da21549 commit 47c68ba
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Editorconfig/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,17 @@
"language": "C#",
"type": "item"
},
"symbols": {
"skipmanualinstructions": {
"type": "parameter",
"dataType": "bool",
"defaultValue": "false",
"description": "Skips displaying manual instructions when they are not necessary, e.g. when this template is used in combination with other mcs templates"
}
},
"postActions": [
{
"condition": "(!skipmanualinstructions)",
"description": "Verify .csproj files",
"manualInstructions": [
{
Expand Down
25 changes: 25 additions & 0 deletions src/WinUI3-App/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@
}
]
}
},
"noeditorconfig": {
"type": "parameter",
"dataType": "bool",
"defaultValue": "false",
"description": "Omits the .editorconfig used to build this template"
}
},
"primaryOutputs": [
Expand Down Expand Up @@ -331,6 +337,12 @@
"UnoWinUIQuickStart.Wasm/manifest.webmanifest",
"UnoWinUIQuickStart.Wasm/Assets/AppIcon-*"
]
},
{
"condition": "(noeditorconfig)",
"exclude": [
"TemplatePostAction.ps1"
]
}
]
}
Expand All @@ -346,6 +358,19 @@
],
"actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025",
"continueOnError": true
},
{
"condition": "(!noeditorconfig)",
"description": "Add the .editorconfig that was used to build this template",
"manualInstructions": [ { "text": "To add the .editorconfig that was used to build this template, run 'dotnet new mcs-editorconfig'" } ],
"actionId": "3A7C4B45-1F5D-4A30-959A-51B88E82B5D2",
"args": {
"executable": "powershell",
"args": "-file TemplatePostAction.ps1",
"redirectStandardError": false,
"redirectStandardOutput": false
},
"continueOnError": false
}
]
}
6 changes: 6 additions & 0 deletions src/WinUI3-App/TemplatePostAction.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Start-Sleep -seconds 1 # Workaround to prevent exception from lock on dotnet.exe log file when nesting dotnet.exe invocations (log filename includes current time down to seconds)

$solutionfolder = Split-Path -Path "$PSCommandPath" -Parent
dotnet new mcs-editorconfig -o "$solutionfolder" --skipmanualinstructions

Remove-Item "$PSCommandPath" -Force
6 changes: 6 additions & 0 deletions src/WinUI3-App/UnoWinUIQuickStart/App.logic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs ar

#if NET6_0_OR_GREATER && WINDOWS && !HAS_UNO
MainWindow = new Window();
{ // Set startup window size
nint hWnd = WinRT.Interop.WindowNative.GetWindowHandle(MainWindow);
var windowId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(hWnd);
var appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(windowId);
appWindow?.Resize(new(500, 1180));
}
MainWindow.Activate();
#else
MainWindow = Microsoft.UI.Xaml.Window.Current;
Expand Down

0 comments on commit 47c68ba

Please sign in to comment.