gpt4 book ai didi

powershell - 从 PowerShell 运行 MSBuild

转载 作者:行者123 更新时间:2023-12-01 11:20:43 25 4
gpt4 key购买 nike

我在 PowerShell 文件中有以下代码:

$msbuild = 'C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe'
iex ("& {0} {1}" -f $msbuild, "-version")

我得到的错误是:

x86 : The term 'x86' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.



我已经尝试了很多东西,但我无法在脚本中使用字符串变量让 PowerShell 工作。我更一般的目标是运行具有以下性质的脚本
iex ("{0} {1} {2}" -f $msbuild,$project_name,$config)

最佳答案

您必须用引号将路径括起来:

$msbuild = '"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe"'
iex ("& {0} {1}" -f $msbuild, "-version")

关于powershell - 从 PowerShell 运行 MSBuild,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43983865/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com