【问题标题】:Powershell command not working when run by octopus deploy章鱼部署运行时Powershell命令不起作用
【发布时间】:2014-03-20 13:59:40
【问题描述】:

我有几个步骤来解决这个问题,但我不知道还能做什么。我的最终目标是检查我的“app.exe”文件版本。当我在服务器上手动运行它时,两个脚本版本都可以工作。但是当 Octopus 运行时,两个版本都失败并出现不同的错误

版本 1:

  $file = "C:\Octopus\Applications\AppStartUp\38.2.19.0\app.exe"
  $fileVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($file).FileVersion

我得到错误:

return [System.Diagnostics.FileVersionInfo]::GetVersionInfo <<<< ($file).    FileVersion
    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : DotNetMethodException

版本 2:

$file = "C:\Octopus\Applications\AppStartUp\38.2.19.0\app.exe"
(Get-Command "$file").FileVersionInfo.Fileversion

错误信息

Export-ModuleMember : The Export-ModuleMember cmdlet can only be called from in side a module. At C:\Octopus\Applications\CSIS_DEV\ESG.CSIS.StartUp\38.2.19.0\deployment\clickOnceLib.ps1:35 char:20
    + Export-ModuleMember <<<<  -function * -alias *
    + CategoryInfo          : PermissionDenied: (:) [Export-ModuleMember], InvalidOperationException
    + FullyQualifiedErrorId : Modules_CanOnlyExecuteExportModuleMemberInsideAModule,Microsoft.PowerShell.Commands.ExportModuleMemberCommand 
Get-Command : The term 'C:\Octopus\Applications\CSIS_DEV\ESG.CSIS.StartUp\38.2.19.0\ESG.CSIS.StartUp.exe' 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.
    At C:\Octopus\Applications\CSIS_DEV\ESG.CSIS.StartUp\38.2.19.0\deployment\clickOnceLib.ps1:32 char:24
    +     return (Get-Command <<<<  "$file").FileVersionInfo.Fileversion
    + CategoryInfo          : ObjectNotFound: (C:\Octopus\Appl...SIS.StartUp.exe:String) [Get-Command], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand

这些消息的任何 Insite 以及为什么只有在章鱼中运行时才会发生这种情况会很棒。

【问题讨论】:

    标签: powershell octopus-deploy


    【解决方案1】:

    您的脚本似乎无法访问该文件,或者该文件不存在。检查以确保C:\Octopus\Applications\CSIS_DEV\ESG.CSIS.StartUp\38.2.19.0\ESG.CSIS.StartUp.exe 存在并且触手在其下运行的用户可以访问(使用 Windows 有效权限)。

    还要确保在脚本运行时它就在那里,你没有提到这是一个单独的步骤,PreDeploy.ps1、Deploy.ps1 还是 PostDeploy.ps1 脚本

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-10
      • 2017-05-01
      • 1970-01-01
      • 2012-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多