【发布时间】:2021-09-04 23:34:28
【问题描述】:
我正在将我的后端升级到 dotnet 5.0,但现在我的 aws buildpiplines 在 aws codebuild 步骤上失败了。我正在运行的 docker 镜像是Ubuntu 20.04 aws/codebuild/standard:5.0,它绝对支持 dotnet5.0。
这是在 codebuild 上看到的错误:
Step 6/11 : RUN dotnet publish -c Release -o out
---> Running in f2d4da28b101
5.0.301 [/usr/share/dotnet/sdk]
Could not execute because the application was not found or a compatible .NET SDK is not installed.
Possible reasons for this include:
* You intended to execute a .NET program:
The application 'publish' does not exist.
* You intended to execute a .NET SDK command:
A compatible installed .NET SDK for global.json version [5.0.202] from [/app/global.json] was not found.
Install the [5.0.202] .NET SDK or update [/app/global.json] with an installed .NET SDK:
The command '/bin/sh -c dotnet publish -c Release -o out' returned a non-zero code: 145
发现这真的很奇怪,因为我下面的 dockerfile 清楚地提取了 sdk 版本
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:5.0
WORKDIR /app
COPY --from=build-env /app/out .
ENV ASPNETCORE_URLS http://*:443
ENTRYPOINT ["dotnet", "user-bff.dll"]
version: 0.2
phases:
install:
runtime-versions:
dotnet: 5.0
pre_build:
commands:
- echo Logging in to Amazon ECR
- aws ecr get-login-password | docker login --username AWS --password-stdin $REPOSITORY_URI
- IMAGE_URI="${REPOSITORY_URI}:latest"
build:
commands:
- echo Build started on `date`
- echo Building the Docker image...
- docker build --tag "$IMAGE_URI" .
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:latest
post_build:
commands:
- echo Build completed on `date`
- echo Push the latest Docker Image...
- docker push "$IMAGE_URI"
- printf '[{"name":"user-bff","imageUri":"%s"}]' "$IMAGE_URI" > images.json
artifacts:
files:
- buildspec.yml
- images.json
这也是我的构建规范文件
寻求任何可能的帮助!认为它可能与 ubuntu 有关,因为它在我的本地 Windows 机器上运行良好。我唯一改变的是运行时映像、代码构建映像以及将我的应用程序更新到 dotnet 5.0
【问题讨论】:
-
同时检查 build.docker 文件
标签: c# amazon-web-services docker .net-core aws-codebuild