Open
Description
Describe the bug
Failed to publish aot
publish command:
dotnet publish -f net7.0 -c Release -p:AssemblyName=http -p:PublishAot=true -r linux-x64 -o /app/artifacts
The errors:
error NETSDK1183: Unable to optimize assemblies for Ahead of time compilation: a valid runtime package was not found. Either set the PublishAot property to false, or use a supported runtime identifier when publishing. When targeting .NET 7 or higher, make sure to restore packages with the PublishAot property set to true. [/app/src/HTTPie/HTTPie.csproj::TargetFramework=net6.0]
To Reproduce
Code: https://github.com/WeihanLi/dotnet-httpie/tree/105a17b3e7e0a0c00c2c140498fe1c2ffa17ddeb
Build the dockerfile for the docker image
FROM mcr.microsoft.com/dotnet/runtime-deps:7.0-alpine AS base
LABEL Maintainer="WeihanLi"
FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS build-env
# Install NativeAOT build prerequisites
RUN apk update && apk add clang gcc lld musl-dev build-base zlib-dev
WORKDIR /app
COPY ./src/ ./src/
COPY ./build/ ./build/
COPY ./Directory.Build.props ./
COPY ./Directory.Build.targets ./
COPY ./Directory.Packages.props ./
WORKDIR /app/src/HTTPie/
RUN dotnet publish -f net7.0 -c Release -p:AssemblyName=http -p:PublishAot=true -r linux-x64 -o /app/artifacts
FROM base AS final
COPY --from=build-env /app/artifacts/http /root/.dotnet/tools/http
RUN ln -s /root/.dotnet/tools/http /root/.dotnet/tools/dotnet-http
ENV PATH="/root/.dotnet/tools:${PATH}"
Exceptions (if any)
Further technical details
- Include the output of
dotnet --info
7.0.100-rc.1.22431.12