-
Notifications
You must be signed in to change notification settings - Fork 7.6k
CmdPal: Get version when running as unpacked app #44540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CmdPal: Get version when running as unpacked app #44540
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates the Settings/General page to safely retrieve version information for both packaged and unpackaged apps. It prevents crashes when running as an unpackaged application by adding a fallback mechanism that reads the version from the process executable, with a final fallback to display "?" when the version cannot be determined.
Changes:
- Added new localized resource string "Settings_GeneralPage_VersionNo" for formatting the version display
- Refactored ApplicationVersion property to use a try-pattern for both packaged and assembly version retrieval
- Added TryGetPackagedVersion method to safely handle packaged app scenarios
- Added TryGetAssemblyVersion method to retrieve version from executable for unpackaged apps
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/modules/cmdpal/Microsoft.CmdPal.UI/Strings/en-us/Resources.resw | Added localization string for version display format |
| src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/GeneralPage.xaml.cs | Implemented robust version retrieval with fallbacks for both packaged and unpackaged scenarios |
| return false; | ||
| } | ||
|
|
||
| var info = FileVersionInfo.GetVersionInfo(processPath); |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the executable lacks version information, FileVersionInfo will return zeros for all version parts, resulting in "0.0.0.0" being displayed. Following the pattern used elsewhere in the codebase (e.g., PluginMetadata.cs), consider checking if the version is "0.0.0.0" and returning false in that case, so the fallback "?" is displayed instead of a misleading "Version 0.0.0.0".
| var info = FileVersionInfo.GetVersionInfo(processPath); | |
| var info = FileVersionInfo.GetVersionInfo(processPath); | |
| if (info.FileMajorPart == 0 && info.FileMinorPart == 0 && info.FileBuildPart == 0 && info.FilePrivatePart == 0) | |
| { | |
| // Executable lacks version information; signal failure so the caller can use the fallback. | |
| return false; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Summary of the Pull Request
This PR updates how the Settings / General page retrieves version information for unpackaged apps.
It prevents a crash by reading the version from the process executable, with a fallback to displaying a question mark when the version cannot be determined.
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed