Difference between revisions of "Publish Project to AWS"

From MgmtWiki
Jump to: navigation, search
Line 62: Line 62:
* [https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publish dotnet publish]
* [https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publish dotnet publish]
* [https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/ebextensions.html Advanced environment customization with configuration files (.ebextensions)]
[[Category:Best Practice]]
[[Category:Best Practice]]

Revision as of 11:07, 6 June 2020

Full Title or Meme

Build and zip a Visual Studio dot net core 2.1+ Project for publication to Amazon Web Services.




From the website Deploying an ASP.NET core application with Elastic Beanstalk.

  1. Prepare a project with all dependencies marked.
  2. Ensure that the main project to be deployed by Visual Studio to AWS elasticbeanstalk has a folder in the root of that main project.
  3. Add a deployment file (see section below)
  4. from Powershell type "dotnet publish" (this and future commands are typed in the project directory)
  5. Now the deployment manifest file and a directory of all the files to be loaded up to the AWS elasticbeanstalk a ready for creating the deployment bundle.
  6. Run the Powershell script that creates the zip file of the code to install the soltuion and the zip that up with the deployment manifest.
  7. Upload the deployment bundle to the S3 instance for the app in AWS
  8. Open the AWS Explorer in Visual Studio (fro the View tab at the top ribbon)
  9. Navigate to the S3 file just uploaded and right click on the file, then click on "Create Pre-signed URL"
  10. Pick a time for the URL to expire that will allow the completion of the process and click "Generate", copy the URL so you don't lose it and click ok
  11. Go back to the project in Visual Studio to the .ebextenstion folder and the RunRegistry.config file of the main project that is being deployed
  12. Note that Visual studio thinks that .config files are xml, so don't open it in Visual Studio, but in Notepad (rt-click open with)
  13. Add the code single to that shown below to this file

Deployment File

 "manifestVersion": 1,
 "deployments": {
   "aspNetCoreWeb": [
       "name": "my-dotnet-core-app",
       "parameters": {
         "archive": "dotnet-core-app.zip"
Example dotnet-core-bundle.zip
-- aws-windows-deployment-manifest.json
-- dotnet-core-app.zip
PS C:\Users\rp_to_000\Documents\TopCat\Repos\TrustRegistry3\RegistryServer> dotnet publish
Microsoft (R) Build Engine version 16.6.0+5ff7b0c9e for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  SimpleService -> C:\Users\rp_to_000\Documents\TopCat\Repos\TrustRegistry3\SimpleService\bin\Debug\netcoreapp3.1\SimpleService.dll
  CredStore -> C:\Users\rp_to_000\Documents\TopCat\Repos\TrustRegistry3\CredStore\bin\Debug\netcoreapp3.1\CredStore.dll
  MonitorService -> C:\Users\rp_to_000\Documents\TopCat\Repos\TrustRegistry3\MonitorService\bin\Debug\netcoreapp3.1\MonitorService.dll
  RegistryServer -> C:\Users\rp_to_000\Documents\TopCat\Repos\TrustRegistry3\RegistryServer\bin\Debug\netcoreapp3.1\RegistryServer.dll
  RegistryServer -> C:\Users\rp_to_000\Documents\TopCat\Repos\TrustRegistry3\RegistryServer\bin\Debug\netcoreapp3.1\publish\
PS C:\Users\rp_to_000\Documents\TopCat\Repos\TrustRegistry3\RegistryServer>