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.
This commit is contained in:
Dan Thompson 2020-05-16 17:40:10 -07:00 committed by GitHub
parent b46d393061
commit e1c139128e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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!" == "" (