We want to deploy an ASP.NET MVC web application and windows service to elastic beanstalk. We use awsdeploy.exe to handle the deployment of the web application. The service and the web application share a configuration and libraries. To deploy the service my plan was:
- Include the windows service exe in the web deployment package \bin directory and deploy the service and web application together
- Use an .ebextensions file to install the service
However, this doens't seem to work as the .ebextensions actions are executed before the webdeploy package is installed so the service exe isn't available to be installed.
It seems that my options are:
S3
Zip the service exe and publish it to S3 so it is available to be installed by .ebextensions when the web application is deployed.
This isn't ideal as the service and web app share dependencies + configuration. The service would need to be installed with a separate set of dependencies and config as it would need to be up and running before the web application can be updated.
Post Deploy Scripts
Use the unsupported post deployment script technique which I'd need to translate into the windows world.
Windows directory = C:\Program Files\Amazon\ElasticBeanstalk\hooks\appdeploy\post There is a .ps1 script file there. (Is .cmd supported?)
Use the Web Deploy Package as a .ebextensions zip source
We could be able to use the webdeploy package @ "C:\cfn\ebdata\source_bundle.zip" as a source, unzip it and install the service from there. The problem is the internal paths in the zip are dependent on how the user's machine how built it was setup so finding the exe in the unzipped file structure would be tricky. Example path = "Content\C_C\gitdeploy\blah\blahSolution\blahProject\obj\awsTestDebug\Package\PackageTmp\bin\myservice.exe"
Any suggestions on which approach to take?
Edit
Taking Jim's advice I used container_commands and it works nicely. My .ebextensions/install.config looks like this..
...
container_commands:
installTaskRunner:
command: C:\\inetpub\\wwwroot\\App_Data\\installTaskRunner.cmd >> C:\\inetpub\\wwwroot\\App_Data\\installTaskRunner.log
commands:
stop_service:
command: net stop MyService
ignoreErrors: true
...
The batch file looks like this...
pushd C:\inetpub\wwwroot\bin
C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\installutil MyService.exe
net start MyService
popd
Edit #2
Added additional command to instal.config to stop the service before the webdeploy package is applied as the service.exe locks some deployment files.