Powershell 启动巧克力程序管理员罐';在父文件夹中找不到脚本
我有一个非常基本的Powershell 启动巧克力程序管理员罐';在父文件夹中找不到脚本,powershell,chocolatey,Powershell,Chocolatey,我有一个非常基本的chocolayinstall.ps1脚本,它应该调用父文件夹中的另一个Powershell脚本。这是我的项目结构: project/ service-install.ps1 tools/ chocolatey/ ChocolateyInstall.ps1 这是我的巧克力摊。ps1: # Install the windows service Start-ChocolateyProcessAsAdmin -ExeToRun "powershell
chocolayinstall.ps1
脚本,它应该调用父文件夹中的另一个Powershell脚本。这是我的项目结构:
project/
service-install.ps1
tools/
chocolatey/
ChocolateyInstall.ps1
这是我的巧克力摊。ps1
:
# Install the windows service
Start-ChocolateyProcessAsAdmin -ExeToRun "powershell" -Statements "./service-install.ps1" -WorkingDirectory "..\..\"
安装生成包时,巧克力安装.ps1
失败,出现以下错误:
<S S="Error">./service-install.ps1 : The term './service-install.ps1' 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._x000D__x000A_</S>
<S S="Error">At line:7 char:9_x000D__x000A_</S>
<S S="Error">+ ./service-install.ps1_x000D__x000A_</S>
<S S="Error">+ ~~~~~~~~~~~~~~~~~~~~~_x000D__x000A_</S>
<S S="Error"> + CategoryInfo : ObjectNotFound: (./service-install.ps1:String) [], ParentContainsErrorRecordException_x000D__x000A_</S>
<S S="Error"> + FullyQualifiedErrorId : CommandNotFoundException_x000D__x000A_</S>
<S S="Error"> _x000D__x000A_</S>
/service-install.ps1:术语“/service-install.ps1”不能识别为cmdlet、函数、脚本文件或可操作程序的名称。检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试。_x000D_ux000a_
第7行字符:9_x000D_x000A_
+./service-install.ps1_x000D__x000A_
+~~~_
+CategoryInfo:ObjectNotFound:(./service install.ps1:String)[],ParentContainerErrorRecordException\u x000D\u x000A_
+FullyQualifiedErrorId:CommandNotFoundException\u x000D\u x000A_
_x000D_uux000a_
我需要将project/
目录作为workdir运行脚本
为什么服务安装脚本没有正确执行/找到?我已经尝试过的例子,但仍然无法让它发挥作用。在大多数巧克力包装中,你会看到类似的一行:
$ScriptRoot = Split-Path $MyInvocation.MyCommand.Definition
这将为您提供当前正在执行的脚本的位置,即ChocolateInStall.ps1文件。从那里,您应该能够“找到”要执行的脚本。我有,没有区别。我不认为这是在cmd提示符下运行的,因为我指定exe作为
powershell