使用GitHub Actions将ASP.NET Core应用程序部署到AWS Beanstalk [英] ASP.NET Core app deploy to AWS Beanstalk using GitHub Actions
问题描述
我正在尝试为我的ASP.NET Core 3.1应用程序使用GitHub Actions和AWS Beanstalk(Linux)构建CD管道. 我已将YML文件配置如下:
I am trying to build a CD pipeline using the GitHub Actions and AWS Beanstalk (Linux) for my ASP.NET Core 3.1 app. I have configured the YML file as follows:
- name: dotnet Build
run: dotnet build src/SLNNAME.sln -c Release --no-restore
- name: dotnet Publish
run: |
dotnet publish src/SLNNAME.Server/SLNAME.Server.Web/SLNNAME.Server.Web.csproj -c Release -o staging_SLNNAME_server -r linux-x64
- name: Build deployment package
run: zip -r staging-server-deploy.zip staging_SLNNAME_server
..
- name: Deploy to AWS Beanstalk
uses: einaregilsson/beanstalk-deploy@v10
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
region: ${{ secrets.AWS_REGION }}
application_name: SLNNAME-staging-app-web
environment_name: SLNNAME-staging-server
version_label: "staging-app-web-${{ steps.format-time.outputs.replaced }}"
deployment_package: staging-server-deploy.zip
但是在部署到AWS期间发生错误.特别是,查看Beanstalk日志,我会看到以下错误:
But an error occurs during the deployment to AWS. In particular, looking at the Beanstalk logs I can read the following error:
[ERROR] An error occurred during execution of command [app-deploy] - [CheckProcfileForDotNetCoreApplication]. Stop running the command. Error: error stat /var/app/staging/staging_SLNNAME_server/SLNNAME.dll: no such file or directory with file /var/app/staging/staging_SLNNAME_server/SLNNAME.dll
基本上,我认为它是在寻找具有解决方案名称而不是项目名称的DLL-SLNName.Server.Web.我不知道它在哪里获取解决方案名称,因为它不是zip文件的一部分.
我也尝试了--self-contained
标志,但是错误完全相同.
Basically, I think it is looking for a DLL with the solution name instead of the project name - SLNName.Server.Web. I wonder yet where it is picking up the solution name, since it is not part of the zip file.
I gave a try with the --self-contained
flag as well, but the error is exactly the same.
即使我尝试使用AWS工具之王Visual Studio扩展发布解决方案,也遇到此错误.
I have this error even if I try to publish the solution using the AWS toolking Visual Studio extension.
我发现解决此问题的唯一方法是更改项目输出DLL名称以与解决方案相匹配,但这对我来说没有任何意义-将来我可能会遇到更多问题.
The only way I have found to fix this is to change the project output DLL name to match the solution one, but it doesn't make any sense to me - I might have more problems in future.
谢谢
推荐答案
今天,我收到了来自AWS支持的电子邮件,指出该问题已解决. 我已经尝试过了,而且实际上可行!
Today I received an email from AWS support saying the issue has been fixed. I have tried it and actually it works!
请确保使用Linux 2/2.0.1作为平台
Please be sure to use Linux 2/2.0.1 as platform
这篇关于使用GitHub Actions将ASP.NET Core应用程序部署到AWS Beanstalk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!