Deploy ASP.NET Core Apps to AWS EC2

Before deploying ASP.NET Core apps to AWS EC2, the EC2 Linux has to be setup completely for running .NET Core app (like installing .NET Core 2.1 or .NET Core 2.0, installing Apache 2 (Httpd) and setting the reverse mechanism for localhost:5000, etc.)
 
I have an ASP.NET Core project that is named VodManageSystem in Visual Studio on Mac and I want to deploy it to AWS EC2 then the following steps have to be done.

1. Publish VodManageSystem Project

                dotnet publish --configuration Release


2. Login to AWS

    The three command lines are included inside loginAmazonEC2.sh under my EC2 home directory so I can just go to home directory and execute the following tow commands


3. Copy the published VodManageSystem package to AWS

    Execute the following command:
    or execute the following command because I put this long command line inside the bash file named scp_aspdotnetcore_web.sh.
    The published VodManageSystem package will be copied to asp_dotnetcore_web directory under my EC2 home directory, which is


4. Kill the running processes of VodManageSystem's .NET Core app

    First of all, Display all running process of my EC2 instance on AWS by executing the following command to find out the its processes ids
    Second, kill the running processes depending on ids that are found

5. Delete the old files and directories of the VodManageSystem package that was deployed before

    The published VodManageSystem package was put under directory, /opt/VodManageSystem on AWS EC2 instance so go to this directory by executing the following command
    Then remove the whole package under this directory (/opt/VodManageSystem) using command:

6. Move all files and directories of VodManageSystem package that was just copied to aspdotnetcore_web directory under EC2 home directory to /opt/VodManageSystem


7. Check if VodManageSystem.dll can be run


8. If it did not work then check what went wrong and fix it by going through the above steps

9. If it works then reboot the AWS EC2 instance (the EC2 linux system will start VodManageSystem.dll when it starts because the auto execution was setup before)


10. The settings for auto executing when AWS EC2 instance starts

                    cd /opt/VodManageSystem
                    /opt/dotnet/dotnet VodManageSystem.dll
                    exit 0

                    sh /opt/VodManageSystem.sh