From e1c139128e28e8734638907f4aed21104a654bcb Mon Sep 17 00:00:00 2001 From: Dan Thompson Date: Sat, 16 May 2020 17:40:10 -0700 Subject: [PATCH] Make bcz not run personal PowerShell profile script (-NoProfile) (#5945) The `bcz.cmd` script calls a powershell helper script (bx.ps1), but (previous to this change) did not pass `-NoProfile`, which means that powershell.exe would load and run one's personal profile script, which can only slow things down, and worse, can change default behaviors (such as turning on strict mode by default, which will cause scripts that don't run cleanly with strict mode to generate lots of errors--such as bx.ps1). This change amends the powershell.exe command line to pass -NoProfile, as well as to set the execution policy and ensure that interactive prompts can't inadvertently show up (normal best practices for use of powershell in build scripts). This change will speed things up (probably negligibly, but still) and (more importantly) prevent non-determinism and errors that could result from running people's profile scripts when running the helper bx.ps1. --- tools/bcz.cmd | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/bcz.cmd b/tools/bcz.cmd index 7e2c8c4f6..4398a8b46 100644 --- a/tools/bcz.cmd +++ b/tools/bcz.cmd @@ -97,9 +97,8 @@ set MSBuildEmitSolution=1 set MSBuildEmitSolution= rem Use bx.ps1 to figure out which target we're looking at -set _BX_SCRIPT=powershell bx.ps1 set _OUTPUT= -FOR /F "tokens=* USEBACKQ" %%F IN (`powershell bx.ps1 2^> NUL`) DO ( +FOR /F "tokens=* USEBACKQ" %%F IN (`powershell -NoProfile -ExecutionPolicy Bypass -NonInteractive bx.ps1 2^> NUL`) DO ( set _OUTPUT=%%F ) if "!_OUTPUT!" == "" (