如何获得在AWS Beanstalk Windows实例上运行的PostInstall PowerShell脚本 [英] How to get a postInstall PowerShell script working on an AWS Beanstalk Windows instance

查看:102
本文介绍了如何获得在AWS Beanstalk Windows实例上运行的PostInstall PowerShell脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在部署到AWS Beanstalk Windows IIS实例后执行PowerShell脚本.为此,我编写了一个aws-windows-deployment-manifest.json文件,如下所示:

I am trying to execute a PowerShell script after deployment to an AWS Beanstalk Windows IIS instance. For this, I have written a aws-windows-deployment-manifest.json file as follows:

{
  "manifestVersion": 1,
  "iisConfig": {
    "appPools": [
      {
        "name": "AppPoolName",
        "recycling": {
          "regularTimeInterval": 10
        }
      }
    ]
  },
  "deployments": {
    "msDeploy": [
      {
        "name": "app",
        "parameters": {
          "appBundle": "App.zip",
          "iisPath": "/",
          "iisWebSite": "Default Web Site",
          "appPool": "AppPoolName"
        },
        "scripts": {
          "postInstall": {
            "file": "PostInstallSetup.ps1"
          }
        }
      }
    ]
  }
}

我的PostInstallSetup.ps1脚本非常简单,它仅包含:

My PostInstallSetup.ps1 script is super-simple, it contains just:

"Hello, World!"

仍然,它不起作用.在部署的日志文件中,我收到以下消息:

Still, it does not work. In the log file of the deployment I get messages like these:

Info: Adding file (Default Web Site/Web.config).
---------- Executing command "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy unrestricted -NonInteractive -NoProfile -Command  "& { & \"C:\Staging\PostInstallSetup.ps1\"; exit $LastExitCode }" " ----------
Info: Adding file (Default Web Site/Readme.txt).
Error during deployment: The directory name is invalid
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at AWS.DeploymentCommands.Utilities.ExecuteCommand(String cwd, String command, String arguments, ILogger logger, Boolean throwOnError) in D:\Jenkins\jobs\aws.deploytools-build\workspace\src\AWS.DeploymentCommands\Utilities.cs:line 181
   at AWS.DeploymentCommands.Utilities.ExecutePowerShellScript(String cwd, String script, ILogger logger) in D:\Jenkins\jobs\aws.deploytools-build\workspace\src\AWS.DeploymentCommands\Utilities.cs:line 107
   at AWS.DeploymentCommands.Commands.BaseScriptableCommand.ExecuteScript(ScriptDeclaration script, String cwd) in D:\Jenkins\jobs\aws.deploytools-build\workspace\src\AWS.DeploymentCommands\Commands\BaseScriptableCommand.cs:line 84
   at AWS.DeploymentCommands.Commands.DeployMSDeployPackages.DoInstall() in D:\Jenkins\jobs\aws.deploytools-build\workspace\src\AWS.DeploymentCommands\Commands\DeployMSDeployPackages.cs:line 105
Info: Adding file (Default Web Site/WebC.Web.config).
---------- Executing command "C:\Windows\system32\iisreset.exe /start" ----------

最终结果是部署已完成,Web应用程序正在运行,但尚未执行PostInstallSetup.ps1脚本.

The end result is that the deployment has completed, the web app is working, but the PostInstallSetup.ps1 script has not been executed.

清单文件中是否有错误?还是我需要将PostInstallSetup.ps1脚本放置在其他地方?

Do I have an error in the manifest file? Or do I need to place the PostInstallSetup.ps1 script somewhere else?

我已将PostInstallSetup.ps1脚本简化为"Hello World",只是为了排除该脚本中的问题破坏了部署.

I have reduced the PostInstallSetup.ps1 script to "Hello World" just to rule out that issues in the script are breaking the deploy.

推荐答案

事实证明,脚本/postInstall方法与msDeploy结合使用效果不佳.它确实适用于.NET Core类型部署,因此,作为一种解决方法,我添加了一个虚拟.NET Core程序包,将postInstall代码放在其中.

It turned out that the scripts / postInstall method does not work well in combination with msDeploy. It did work with the .NET Core type deploy, so as a workaround I added a dummy .NET Core package placed my postInstall code in there.

这篇关于如何获得在AWS Beanstalk Windows实例上运行的PostInstall PowerShell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆