Question:
I am trying to remove some verbosity from a choco install
command within AppVeyor. Here is what I been trying (as suggested here):
1 2 3 4 5 6 |
if (Test-Path "C:/ProgramData/chocolatey/bin/swig.exe") { echo "using swig from cache" } else { choco install swig > NUL } |
However it fails with:
1 2 3 4 5 6 7 8 9 10 |
Redirection to 'NUL' failed: FileStream will not open Win32 devices such as disk partitions and tape drives. Avoid use of "\\.\" in the path. At line:4 char:5 + choco install swig > NUL + ~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : RedirectionFailed Command executed with exception: Redirection to 'NUL' failed: FileStream will not open Win32 devices such as disk partitions and tape drives. Avoid use of "\\.\" in the path. |
So my question is there a way to suppress the verbosity of a choco install
command within PowerShell on AppVeyor?
Answer:
nul
is batch syntax. In PowerShell you can use $null
instead, as Mathias R. Jessen pointed out in his comment:
1 2 |
choco install swig > $null |
Other options are piping into the
Out-Null
cmdlet, collecting the output in a variable, or casting it to void
:
1 2 3 4 |
choco install swig | Out-Null $dummy = choco install swig [void](choco install swig) |