在powershell脚本中使用包含多个参数的单个可延展对象
我有一堆参数,我想多次传递给一个命令。为了减少写入相同参数的次数,从而减少我必须维护这些参数的位置数,我认为将它们全部放在字符串中并传递该字符串是个好主意。但是,该命令将整个字符串视为单个参数,这自然会导致问题。 这是我想要实现的脚本示例。(这是用于构建GDAL,顺便说一句)。 $baseOptions = "MSVC_VER=1910 GDAL_HOME='$outputDir\' SWIG='$swig'" #Building x86 if($x86 -eq $true) { $options = $baseOptions + " BINDIR='$outputDir\x86\bin' LIBDIR='$outputDir\x86\lib' INCDIR='$outputDir\x86\include'" if($useLibcurl -eq $true) { $options += " CURL_DIR='$libcurlDir/x86' CURL_INC='-I$libcurlDir/include' CURL_LIB='$libcurlDir/x86/lib/libcurl.lib wsock32.lib wldap32.lib winmm.lib'" } #Building x86 release if($release -eq $true) { nmake /f makefile.vc $options nmake /f makefile.vc install …