0

我想在部署到AWS Beanstalk Windows IIS实例后执行PowerShell脚本。对于这一点,我已经写了AWS-Windows的部署,manifest.json档案如下:如何获取在AWS Beanstalk Windows实例上工作的postInstall PowerShell脚本

{ 
 
    "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脚本是超级简单,只包含:

"Hello, World!" 

不过,这是行不通的。在部署的日志文件,我得到的消息像这样:

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脚本尚未执行。

我是否在清单文件中的错误?或者我需要将PostInstallSetup.ps1脚本放在别的地方吗?

我已经减少了PostInstallSetup.ps1脚本为“Hello World”只是为了排除脚本问题打破了部署。

回答

0

原来的脚本/后安装方法不能很好地结合msDeploy工作。它确实与.NET Core类型的deploy一起工作,所以作为一种解决方法,我添加了一个虚拟的.NET Core软件包,将postInstall代码放在那里。

相关问题