Reputation: 901
Does anyone have a link to a solid example of the scripts necessary to build an ASP.NET MVC project, package it up for awsdeploy and then deploy it to Elastic Beanstalk all via the command line? The point and click tools in VisualStudio provided by the Amazon tools are great until the team starts to grow and you need to automate with a build server.
Any help would be appreciated.
Upvotes: 1
Views: 902
Reputation: 147
To deploy an ASP.NET project to Elastic Beanstalk using command line, you need to accomplish two steps:
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
Upvotes: 4