Hide console window for launch/ui verbs (fixes #131)#205
Open
CodyBatt wants to merge 1 commit into
Open
Conversation
- Upgrade from .NET 6 to .NET 8 - Call FreeConsole() on Windows for 'launch' and 'ui' verbs to detach from the console, causing the OS to destroy the console window when SCALUS is invoked as a protocol handler from a browser - Add --debug flag to launch/ui verbs to keep console visible for troubleshooting - CLI commands (info, register, --help, etc.) remain unaffected - Update RuntimeIdentifiers from win10-x64 to win-x64 for .NET 8 - Bump package versions (Newtonsoft.Json, ASP.NET Core MVC, System.Security.Cryptography.ProtectedData)
There was a problem hiding this comment.
Pull request overview
This PR upgrades SCALUS to .NET 8 and aims to prevent a console window from appearing when SCALUS is invoked as a protocol handler (notably for the launch and default ui verbs), while adding a --debug flag to keep the console visible for troubleshooting.
Changes:
- Upgrade projects from
net6.0tonet8.0and update Windows RID fromwin10-x64towin-x64. - Detach from the Windows console for
launch/uiinvocations viaFreeConsole(), with--debugto opt out. - Bump select package versions (e.g., Newtonsoft.Json, ASP.NET Core MVC NewtonsoftJson, ProtectedData).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/OneIdentity.Scalus.Test.csproj | Upgrade test project to .NET 8, update RID and Newtonsoft.Json. |
| src/Ui/Options.cs | Add --debug flag to the ui verb. |
| src/Program.cs | Implement console detaching behavior and --debug detection logic. |
| src/OneIdentity.Scalus.csproj | Upgrade main project to .NET 8, update RID, warning suppressions, and package versions. |
| src/Launch/Options.cs | Add --debug flag to the launch verb. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+50
to
+53
| if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && ShouldHideConsole(args)) | ||
| { | ||
| FreeConsole(); | ||
| } |
Comment on lines
+141
to
+148
| // --debug flag keeps the console visible for troubleshooting | ||
| if (args.Any(a => string.Equals(a, "--debug", StringComparison.OrdinalIgnoreCase))) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| return string.Equals(args[0], "launch", StringComparison.OrdinalIgnoreCase) || | ||
| string.Equals(args[0], "ui", StringComparison.OrdinalIgnoreCase); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This approach using FreeConsole to detach results in a slight flicker of a console window. An alternative would be to switch the executable to WinExe, but that has other side effects when trying to run scalus commands within the console. Overall I think FreeConsole works better at the cost of a flicker.
Fixes #131