powershell - 将多个参数传递给高级安装程序中的 Powershell 内联脚本
问题描述
我正在使用高级安装程序来创建 msi 包我想在安装完成后将一些文件和文件夹复制到“[APPDIR]”(我知道我可以通过在高级安装程序中将文件和文件夹添加到文件和文件夹部分来做到这一点,但我没有我不想这样做,因为我的文件和文件夹在客户机器的每次安装中都是动态的)我编写了一个如下所示的内联 PowerShell 脚本
> Param( [string] $source, [string] $dest )
$exclude = @('web.config')
> Get-ChildItem $source -Recurse -Exclude $exclude | Copy-Item
> -Destination {Join-Path $dest $_.FullName.Substring($source.length)}
在参数部分,我这样填写"[SourceDir]Project", "[APPDIR]Project"
但它不起作用。为什么?
解决方案
此后,阿巴斯确认问题出在命令行(参数)语法之一:
参数部分 - 从Advanced Installer传递给 PowerShell 脚本的内容- 填写为:
"[SourceDir]Project", "[APPDIR]Project" # !! WRONG, due to the comma
而它应该是:
"[SourceDir]Project" "[APPDIR]Project" # OK: *space-separated* arguments
在 PowerShell 中调用脚本/函数/cmdlet 的工作方式与在shell中一样,而不是在编程语言中;也就是说,您必须用空格分隔正在传递的参数。
相比之下,,
在标记之间使用构造了一个作为单个参数传递的数组。
从 PowerShell 运行Get-Help about_Command_Syntax
以获取更多信息。
推荐阅读
- python - 箱包装问题的变化 - 单个箱中最多一件物品
- flutter - Flutter 用 Container 等任何小部件包裹软键盘
- vue.js - Vue 3 组合 API:计算过滤数组的问题
- python - CNN:滤波器大小和步幅之间的相关性
- php - 如何在店面主题 WooCommerce 中存储单一图像格式?
- python - 将函数名称列表加入一系列嵌套函数调用
- lightningchart - 禁用图表中的径向背景
- reactjs - 蚂蚁设计获取列索引
- reactjs - 如何确定的出现/消失在类别选择 | 反应JS
- javascript - 有没有办法修改 Vue 组件内的 HTML 标签的内容?