首页 > 解决方案 > 当我尝试通过 TFS Build 运行时,Powershell 脚本未安装 exe

问题描述

我有一个将安装 exe 的 powershell 脚本。当我从 powershell ISE 控制台尝试它时它工作正常,但是当我从 TFS 构建步骤尝试它时它失败了。注意:我的 TFS 用户、代理用户和触发用户是相同的。任何人都可以对这个问题有所了解吗?

Start-Process -FilePath $installerFileName -Verb "runas" -ArgumentList $parameter -Wait

上面的代码是用来安装exe的。$parameter 是自定义参数的列表。

我得到以下错误

[WixSession.GetSession][GetSessionValues]异常:值不能为空。参数名称:s

标签: powershellbuildtfsbuildazure-pipelinesvnext

解决方案


你想安装什么样的exe?是否支持静默安装?如果在安装过程中弹出 UI,则代理需要以交互模式运行。

使用以下命令在我这边测试以使用服务模式安装/卸载记事本++,一切都按预期工作:

start-process -FilePath "D:\Software\npp.7.5.8.Installer.x64.exe" -ArgumentList '/S' -Verb runas -Wait

和:

start-process -FilePath "C:\Program Files\Notepad++\uninstall.exe" -ArgumentList '/S' -Verb runas -Wait

推荐阅读