Skip to content

Commit 888bfb8

Browse files
committed
Make PowerShell script invocation more reliable
- Protect against issues caused from loading default profile - Ignore any warnings that may be generated by auto-loaded modules. Warnings are written to stderr which the Exec then interprets as an error Fixes #46618
1 parent 2d0aade commit 888bfb8

31 files changed

Lines changed: 41 additions & 41 deletions

File tree

doc/devdocs/development/localization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ If you already have a .rc file, copy the string table to a separate txt file and
5252
After generating the resx file, rename the existing rc and h files to ProjName.base.rc and resource.base.h. In the rc file remove the string table which is to be localized and in the .h file remove all `#define`s corresponding to localized resources. In the vcxproj of the C++ project, add the following build event:
5353
```
5454
<Target Name="GenerateResourceFiles" BeforeTargets="PrepareForBuild">
55-
<Exec Command="powershell -NonInteractive -executionpolicy Unrestricted $(SolutionDir)tools\build\convert-resx-to-rc.ps1 $(MSBuildThisFileDirectory) resource.base.h resource.h ProjName.base.rc ProjName.rc" />
55+
<Exec Command="powershell -NoProfile -NonInteractive -executionpolicy Unrestricted -Command &quot;$WarningPreference='SilentlyContinue'; &amp; '$(SolutionDir)tools\build\convert-resx-to-rc.ps1' $(MSBuildThisFileDirectory) resource.base.h resource.h ProjName.base.rc ProjName.rc&quot;" />
5656
</Target>
5757
```
5858

src/ActionRunner/actionRunner.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
44
<Import Project="$(RepoRoot)packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(RepoRoot)packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.props')" />
55
<Target Name="GenerateResourceFiles" BeforeTargets="PrepareForBuild">
6-
<Exec Command="powershell -NonInteractive -executionpolicy Unrestricted $(RepoRoot)tools\build\convert-resx-to-rc.ps1 $(MSBuildThisFileDirectory) resource.base.h resource.h actionRunner.base.rc actionRunner.rc" />
6+
<Exec Command="powershell -NoProfile -NonInteractive -executionpolicy Unrestricted -Command &quot;$PSModuleAutoloadingPreference='none'; &amp; '$(RepoRoot)tools\build\convert-resx-to-rc.ps1' &quot;&quot;$(MSBuildThisFileDirectory)&quot;&quot; resource.base.h resource.h actionRunner.base.rc actionRunner.rc&quot;" />
77
</Target>
88
<PropertyGroup Label="Globals">
99
<VCProjectVersion>16.0</VCProjectVersion>

src/Update/PowerToys.Update.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
44
<Import Project="$(RepoRoot)packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(RepoRoot)packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.props')" />
55
<Target Name="GenerateResourceFiles" BeforeTargets="PrepareForBuild">
6-
<Exec Command="powershell -NonInteractive -executionpolicy Unrestricted $(RepoRoot)tools\build\convert-resx-to-rc.ps1 $(MSBuildThisFileDirectory) resource.base.h resource.h PowerToys.Update.base.rc PowerToys.Update.rc" />
6+
<Exec Command="powershell -NoProfile -NonInteractive -executionpolicy Unrestricted -Command &quot;$PSModuleAutoloadingPreference='none'; &amp; '$(RepoRoot)tools\build\convert-resx-to-rc.ps1' &quot;&quot;$(MSBuildThisFileDirectory)&quot;&quot; resource.base.h resource.h PowerToys.Update.base.rc PowerToys.Update.rc&quot;" />
77
</Target>
88
<PropertyGroup Label="Globals">
99
<VCProjectVersion>16.0</VCProjectVersion>

src/modules/AdvancedPaste/AdvancedPasteModuleInterface/AdvancedPasteModuleInterface.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
44
<Import Project="$(RepoRoot)packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(RepoRoot)packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.props')" />
55
<Target Name="GenerateResourceFiles" BeforeTargets="PrepareForBuild">
6-
<Exec Command="powershell -NonInteractive -executionpolicy Unrestricted ..\..\..\..\tools\build\convert-resx-to-rc.ps1 $(MSBuildThisFileDirectory) resource.base.h resource.h AdvancedPaste.base.rc AdvancedPaste.rc" />
6+
<Exec Command="powershell -NoProfile -NonInteractive -executionpolicy Unrestricted -Command &quot;$PSModuleAutoloadingPreference='none'; &amp; '..\..\..\..\tools\build\convert-resx-to-rc.ps1' &quot;&quot;$(MSBuildThisFileDirectory)&quot;&quot; resource.base.h resource.h AdvancedPaste.base.rc AdvancedPaste.rc&quot;" />
77
</Target>
88
<PropertyGroup Label="Globals">
99
<VCProjectVersion>15.0</VCProjectVersion>

src/modules/EnvironmentVariables/EnvironmentVariablesModuleInterface/EnvironmentVariablesModuleInterface.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
44
<Import Project="$(RepoRoot)packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(RepoRoot)packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.props')" />
55
<Target Name="GenerateResourceFiles" BeforeTargets="PrepareForBuild">
6-
<Exec Command="powershell -NonInteractive -executionpolicy Unrestricted $(RepoRoot)tools\build\convert-resx-to-rc.ps1 $(MSBuildThisFileDirectory) resource.base.h resource.h EnvironmentVariablesModuleInterface.base.rc EnvironmentVariablesModuleInterface.rc" />
6+
<Exec Command="powershell -NoProfile -NonInteractive -executionpolicy Unrestricted -Command &quot;$PSModuleAutoloadingPreference='none'; &amp; '$(RepoRoot)tools\build\convert-resx-to-rc.ps1' &quot;&quot;$(MSBuildThisFileDirectory)&quot;&quot; resource.base.h resource.h EnvironmentVariablesModuleInterface.base.rc EnvironmentVariablesModuleInterface.rc&quot;" />
77
</Target>
88
<PropertyGroup Label="Globals">
99
<VCProjectVersion>17.0</VCProjectVersion>

src/modules/FileLocksmith/FileLocksmithContextMenu/FileLocksmithContextMenu.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
44
<Import Project="$(RepoRoot)packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(RepoRoot)packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.props')" />
55
<Target Name="GenerateResourceFiles" BeforeTargets="PrepareForBuild">
6-
<Exec Command="powershell -NonInteractive -executionpolicy Unrestricted $(RepoRoot)tools\build\convert-resx-to-rc.ps1 $(MSBuildThisFileDirectory) resource.base.h resource.h FileLocksmithContextMenu.base.rc FileLocksmithContextMenu.rc" />
6+
<Exec Command="powershell -NoProfile -NonInteractive -executionpolicy Unrestricted -Command &quot;$PSModuleAutoloadingPreference='none'; &amp; '$(RepoRoot)tools\build\convert-resx-to-rc.ps1' &quot;&quot;$(MSBuildThisFileDirectory)&quot;&quot; resource.base.h resource.h FileLocksmithContextMenu.base.rc FileLocksmithContextMenu.rc&quot;" />
77
</Target>
88
<PropertyGroup Label="Globals">
99
<VCProjectVersion>17.0</VCProjectVersion>

src/modules/FileLocksmith/FileLocksmithExt/FileLocksmithExt.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
44
<Import Project="$(RepoRoot)packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(RepoRoot)packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.props')" />
55
<Target Name="GenerateResourceFiles" BeforeTargets="PrepareForBuild">
6-
<Exec Command="powershell -NonInteractive -executionpolicy Unrestricted $(RepoRoot)tools\build\convert-resx-to-rc.ps1 $(MSBuildThisFileDirectory) resource.base.h resource.h FileLocksmithExt.base.rc FileLocksmithExt.rc" />
6+
<Exec Command="powershell -NoProfile -NonInteractive -executionpolicy Unrestricted -Command &quot;$PSModuleAutoloadingPreference='none'; &amp; '$(RepoRoot)tools\build\convert-resx-to-rc.ps1' &quot;&quot;$(MSBuildThisFileDirectory)&quot;&quot; resource.base.h resource.h FileLocksmithExt.base.rc FileLocksmithExt.rc&quot;" />
77
</Target>
88
<PropertyGroup Label="Globals">
99
<VCProjectVersion>16.0</VCProjectVersion>

src/modules/Hosts/HostsModuleInterface/HostsModuleInterface.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
44
<Import Project="$(RepoRoot)packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(RepoRoot)packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.props')" />
55
<Target Name="GenerateResourceFiles" BeforeTargets="PrepareForBuild">
6-
<Exec Command="powershell -NonInteractive -executionpolicy Unrestricted ..\..\..\..\tools\build\convert-resx-to-rc.ps1 $(MSBuildThisFileDirectory) resource.base.h resource.h HostsModuleInterface.base.rc HostsModuleInterface.rc" />
6+
<Exec Command="powershell -NoProfile -NonInteractive -executionpolicy Unrestricted -Command &quot;$PSModuleAutoloadingPreference='none'; &amp; '..\..\..\..\tools\build\convert-resx-to-rc.ps1' &quot;&quot;$(MSBuildThisFileDirectory)&quot;&quot; resource.base.h resource.h HostsModuleInterface.base.rc HostsModuleInterface.rc&quot;" />
77
</Target>
88
<PropertyGroup Label="Globals">
99
<VCProjectVersion>16.0</VCProjectVersion>

src/modules/NewPlus/NewShellExtensionContextMenu.win10/NewPlus.ShellExtension.win10.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
44
<Import Project="$(RepoRoot)packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(RepoRoot)packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.props')" />
55
<Target Name="GenerateResourceFiles" BeforeTargets="PrepareForBuild">
6-
<Exec Command="powershell -NonInteractive -executionpolicy Unrestricted $(RepoRoot)tools\build\convert-resx-to-rc.ps1 $(MSBuildThisFileDirectory) resource.base.h resource.h new.base.rc new.rc" />
6+
<Exec Command="powershell -NoProfile -NonInteractive -executionpolicy Unrestricted -Command &quot;$PSModuleAutoloadingPreference='none'; &amp; '$(RepoRoot)tools\build\convert-resx-to-rc.ps1' &quot;&quot;$(MSBuildThisFileDirectory)&quot;&quot; resource.base.h resource.h new.base.rc new.rc&quot;" />
77
</Target>
88
<PropertyGroup Label="Globals">
99
<VCProjectVersion>17.0</VCProjectVersion>

src/modules/NewPlus/NewShellExtensionContextMenu/NewShellExtensionContextMenu.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
44
<Import Project="$(RepoRoot)packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(RepoRoot)packages\Microsoft.Windows.CppWinRT.2.0.250303.1\build\native\Microsoft.Windows.CppWinRT.props')" />
55
<Target Name="GenerateResourceFiles" BeforeTargets="PrepareForBuild">
6-
<Exec Command="powershell -NonInteractive -executionpolicy Unrestricted $(RepoRoot)tools\build\convert-resx-to-rc.ps1 $(MSBuildThisFileDirectory) resource.base.h resource.h new.base.rc new.rc" />
6+
<Exec Command="powershell -NoProfile -NonInteractive -executionpolicy Unrestricted -Command &quot;$PSModuleAutoloadingPreference='none'; &amp; '$(RepoRoot)tools\build\convert-resx-to-rc.ps1' &quot;&quot;$(MSBuildThisFileDirectory)&quot;&quot; resource.base.h resource.h new.base.rc new.rc&quot;" />
77
</Target>
88
<PropertyGroup Label="Globals">
99
<VCProjectVersion>17.0</VCProjectVersion>

0 commit comments

Comments
 (0)