Skip to content

PublishAot failed with the NETSDK1183 error #28169

Open
@WeihanLi

Description

@WeihanLi

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}"

CI:
https://weihanli.visualstudio.com/Pipelines/_build/results?buildId=5025&view=logs&j=12f1170f-54f2-53f3-20dd-22fc7dff55f9&t=bd05475d-acb5-5619-3ccb-c46842dbc997

Exceptions (if any)

Further technical details

  • Include the output of dotnet --info
7.0.100-rc.1.22431.12

CI example: https://weihanli.visualstudio.com/Pipelines/_build/results?buildId=5025&view=logs&j=12f1170f-54f2-53f3-20dd-22fc7dff55f9&t=b939ce2a-e73e-5c6a-458a-4f58c0003587

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions