To deploy an ASP.NET project to Elastic Beanstalk using command line, you need to accomplish two steps:
- Build your project into a IIS deploy package
- Send the package using AWSDEPLOY
Step 1: Build your package
Using the msbuild.exe, pass the path of the project, a publish profile option with the package instructions and the "DeployOnBuild" option as true.
msbuild.exe "MyMvcProject.csproj" /p:Configuration=Release /p:PublishProfile=MyMvcProjectProfile /p:DeployOnBuild=True
In the publish profile file (MyMvcProjectProfile.pubxml)
<PropertyGroup>
<WebPublishMethod>Package</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<DesktopBuildPackageLocation>$(SolutionDir)\Build\MyMvcProject.zip</DesktopBuildPackageLocation>
<PackageAsSingleFile>true</PackageAsSingleFile>
<DeployIisAppPath>Default Web Site/</DeployIisAppPath>
</PropertyGroup>
Suggestion: Try use the VisualStudio Publish option to generate this file for the first time and than you can edit it.
Step 2: Send the package to Elastic Beanstalk
Pass the package that you created above, the AWS profile name with the permissions needed to make the Beanstalk Update Environment and a "config" deploy file.
awsdeploy.exe -w -r "-DDeploymentPackage=/Build/MyMvcProject.zip" "-DAWSProfileName=%username%" "beanstalk-deploy-package.txt"
The beanstalk-deploy-package.txt file is used to specify Elastic Beanstalk deploy params
Region = us-east-1
Template = ElasticBeanstalk
UploadBucket = elasticbeanstalk-us-east-1-XXXXXXXXXXXX
Application.Name = MyMvcProject
Environment.Name = production
I hope that following this you can adjust the script to your needs.
You can find more information here on AWS DOCS
Best regards