Make PowerShell script invocation more reliable#46729
Open
flcdrg wants to merge 1 commit into
Open
Conversation
29c5aa8 to
1c9a591
Compare
d108e74 to
77eab34
Compare
6469f9e to
50ea894
Compare
This comment has been minimized.
This comment has been minimized.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the build’s PowerShell-based resource-generation steps to avoid failures caused by user PowerShell profiles and noisy warning output during MSBuild Exec invocations.
Changes:
- Updates many
GenerateResourceFilesMSBuild targets to invokepowershellwith-NoProfile -NonInteractiveand an inline command wrapper. - Suppresses PowerShell warning stream output during these invocations via
$WarningPreference='SilentlyContinue'. - Updates localization documentation to reflect the new recommended MSBuild
Execcommand pattern.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/runner/runner.vcxproj | Updates PowerShell invocation used for runner resource generation. |
| src/modules/previewpane/powerpreview/powerpreview.vcxproj | Updates PowerShell invocation for PowerPreview resource generation. |
| src/modules/previewpane/MarkdownPreviewHandlerCpp/MarkdownPreviewHandlerCpp.vcxproj | Updates PowerShell invocation for Markdown preview handler resources. |
| src/modules/powerrename/dll/PowerRenameExt.vcxproj | Updates PowerShell invocation for PowerRenameExt resources. |
| src/modules/powerrename/PowerRenameContextMenu/PowerRenameContextMenu.vcxproj | Updates PowerShell invocation for PowerRename context menu resources. |
| src/modules/launcher/Microsoft.Launcher/Microsoft.Launcher.vcxproj | Updates PowerShell invocation for Launcher resources. |
| src/modules/keyboardmanager/dll/KeyboardManager.vcxproj | Re-formats project XML and updates PowerShell invocation for resource generation. |
| src/modules/keyboardmanager/KeyboardManagerEditorLibrary/KeyboardManagerEditorLibrary.vcxproj | Updates PowerShell invocation for KeyboardManager editor resources. |
| src/modules/keyboardmanager/KeyboardManagerEditor/KeyboardManagerEditor.vcxproj | Updates PowerShell invocation for KeyboardManager editor resources. |
| src/modules/keyboardmanager/Directory.Build.targets | Updates module-wide PowerShell invocation for KeyboardManager resource generation. |
| src/modules/imageresizer/dll/ImageResizerExt.vcxproj | Updates PowerShell invocation for ImageResizerExt resources. |
| src/modules/imageresizer/ImageResizerContextMenu/ImageResizerContextMenu.vcxproj | Updates PowerShell invocation for ImageResizer context menu resources. |
| src/modules/fancyzones/FancyZonesLib/FancyZonesLib.vcxproj | Updates PowerShell invocation for FancyZones resources. |
| src/modules/colorPicker/ColorPicker/ColorPicker.vcxproj | Updates PowerShell invocation for ColorPicker resources. |
| src/modules/alwaysontop/AlwaysOnTop/AlwaysOnTop.vcxproj | Updates PowerShell invocation for AlwaysOnTop resources. |
| src/modules/Workspaces/WorkspacesWindowArranger/WorkspacesWindowArranger.vcxproj | Updates PowerShell invocation for Workspaces Window Arranger resources. |
| src/modules/Workspaces/WorkspacesSnapshotTool/WorkspacesSnapshotTool.vcxproj | Updates PowerShell invocation for Workspaces Snapshot Tool resources. |
| src/modules/Workspaces/WorkspacesLauncher/WorkspacesLauncher.vcxproj | Updates PowerShell invocation for Workspaces Launcher resources. |
| src/modules/ShortcutGuide/ShortcutGuideModuleInterface/ShortcutGuideModuleInterface.vcxproj | Updates PowerShell invocation for ShortcutGuide module interface resources. |
| src/modules/ShortcutGuide/ShortcutGuide/ShortcutGuide.vcxproj | Updates PowerShell invocation for ShortcutGuide resources. |
| src/modules/PowerOCR/PowerOCRModuleInterface/PowerOCRModuleInterface.vcxproj | Updates PowerShell invocation for PowerOCR module interface resources. |
| src/modules/NewPlus/NewShellExtensionContextMenu/NewShellExtensionContextMenu.vcxproj | Updates PowerShell invocation for NewPlus shell extension resources. |
| src/modules/NewPlus/NewShellExtensionContextMenu.win10/NewPlus.ShellExtension.win10.vcxproj | Updates PowerShell invocation for NewPlus Win10 shell extension resources. |
| src/modules/Hosts/HostsModuleInterface/HostsModuleInterface.vcxproj | Updates PowerShell invocation for Hosts module interface resources. |
| src/modules/FileLocksmith/FileLocksmithExt/FileLocksmithExt.vcxproj | Updates PowerShell invocation for FileLocksmith extension resources. |
| src/modules/FileLocksmith/FileLocksmithContextMenu/FileLocksmithContextMenu.vcxproj | Updates PowerShell invocation for FileLocksmith context menu resources. |
| src/modules/EnvironmentVariables/EnvironmentVariablesModuleInterface/EnvironmentVariablesModuleInterface.vcxproj | Updates PowerShell invocation for Environment Variables module interface resources. |
| src/modules/AdvancedPaste/AdvancedPasteModuleInterface/AdvancedPasteModuleInterface.vcxproj | Updates PowerShell invocation for AdvancedPaste module interface resources. |
| src/Update/PowerToys.Update.vcxproj | Updates PowerShell invocation for Update component resources. |
| src/ActionRunner/actionRunner.vcxproj | Updates PowerShell invocation for ActionRunner resources. |
| doc/devdocs/development/localization.md | Updates guidance/sample command for C++ localization resource generation. |
MuyuanMS
added a commit
to flcdrg/PowerToys
that referenced
this pull request
Apr 28, 2026
…#46729) Address Copilot review: quote $(MSBuildThisFileDirectory) and similar MSBuild path variables with single quotes inside -Command strings to prevent argument splitting when paths contain spaces or special characters. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
4e6b8c1 to
972ae65
Compare
Author
|
Changed to disabling auto-loading of PowerShell modules (rather than just suppressing warnings), and quoting the |
e26518e to
01a9bd2
Compare
b4d6e34 to
888bfb8
Compare
- Protect against issues caused from loading default profile - Don't auto-load modules. Mitigate when unrelated auto-loaded modules may output warnings. As warnings are written to stderr, Exec then interprets that as an error and breaks the build. - Explicitly load necessary modules in convert-resx-to-rc.ps1 Fixes microsoft#46618
888bfb8 to
79f2af8
Compare
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.
Summary of the Pull Request
PR Checklist
Detailed Description of the Pull Request / Additional comments
The build contains PowerShell invocations. The issue with these prior to this change is that they are vulnerable to what ever may be in the current user's PowerShell profile script.
They are also vulnerable to any auto-loaded PowerShell modules that may generate warnings, as the warning output is interpreted as an error by the MSBuild
Exectask.Validation Steps Performed