“Error MSB4018: The “Message” task failed unexpectedly” for ASP.NET Core 8.0 build

I am building an ASP.NET Core 8.0 application for arm64 via a github action. Upon the dotnet restore command, the error in the title is thrown and the build process is aborted. I am building the asp.net template project, there is no additional nuget packages or even additional code. When building the application locally to x64, it works fine.

Here are some relevant files:

Github Workflow file:

name: Build and Push Docker Image

on:
  push:
    branches:
      - testing

jobs:
  build-and-push:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v2
        with:
          platforms: linux/amd64,linux/arm64

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2

      - name: Log in to Docker Hub
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      - name: Extract version from tag
        id: vars
        run: |
          if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
            echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
          else
            echo "VERSION=latest" >> $GITHUB_ENV
          fi

      - name: Build and push Docker image
        run: |
          docker buildx build --no-cache --platform linux/arm64 
            --tag turwaith/pinfo-backend:latest 
            --push 
            --cache-from=type=registry,ref=turwaith/pinfo-backend:cache 
            --cache-to=type=inline 
            -f PinfoBackend/Dockerfile PinfoBackend/.

Dockerfile

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER $APP_UID
WORKDIR /app
EXPOSE 5000

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src

# Copy the project file and restore dependencies
COPY PinfoBackend.csproj ./
RUN dotnet restore "PinfoBackend.csproj" --disable-parallel

# Copy all the source code and build the project
COPY . ./
RUN dotnet build "PinfoBackend.csproj" -c $BUILD_CONFIGURATION

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "PinfoBackend.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false /m:1

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "PinfoBackend.dll"]

And the error that is shown in the github action log:

#14 [build 4/6] RUN dotnet restore "PinfoBackend.csproj" --disable-parallel
#14 10.59   Determining projects to restore...
#14 11.54 /usr/share/dotnet/sdk/8.0.401/NuGet.targets(560,5): error MSB4018: The "Message" task failed unexpectedly. [/src/PinfoBackend.csproj]
#14 11.54 /usr/share/dotnet/sdk/8.0.401/NuGet.targets(560,5): error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object. [/src/PinfoBackend.csproj]
#14 11.54 /usr/share/dotnet/sdk/8.0.401/NuGet.targets(560,5): error MSB4018:    at InvokeStub_Message.set_Text(Object, Span`1) [/src/PinfoBackend.csproj]
#14 11.54 /usr/share/dotnet/sdk/8.0.401/NuGet.targets(560,5): error MSB4018:    at System.Reflection.MethodBaseInvoker.InvokePropertySetter(Object obj, BindingFlags invokeAttr, Binder binder, Object parameter, CultureInfo culture) [/src/PinfoBackend.csproj]
#14 11.54 /usr/share/dotnet/sdk/8.0.401/NuGet.targets(560,14): error MSB4026: The "Text=Restore entry point $(MSBuildProjectFullPath)" parameter for the "Message" task is invalid. [/src/PinfoBackend.csproj]
#14 11.54 /usr/share/dotnet/sdk/8.0.401/NuGet.targets(560,5): error MSB4063: The "Message" task could not be initialized with its input parameters.  [/src/PinfoBackend.csproj]
#14 ERROR: process "/bin/sh -c dotnet restore "PinfoBackend.csproj" --disable-parallel" did not complete successfully: exit code: 1
------
 > importing cache manifest from ***/pinfo-backend:cache:
------
------
 > [build 4/6] RUN dotnet restore "PinfoBackend.csproj" --disable-parallel:
10.59   Determining projects to restore...
or MSB4018:    at System.Reflection.MethodBaseInvoker.InvokePropertySetter(Object obj, BindingFlags invokeAttr, Binder binder, Object parameter, CultureInfo culture) [/src/PinfoBackend.csproj]
11.54 /usr/share/dotnet/sdk/8.0.401/NuGet.targets(560,14): error MSB4026: The "Text=Restore entry point $(MSBuildProjectFullPath)" parameter for the "Message" task is invalid. [/src/PinfoBackend.csproj]
11.54 /usr/share/dotnet/sdk/8.0.401/NuGet.targets(560,5): error MSB4063: The "Message" task could not be initialized with its input parameters.  [/src/PinfoBackend.csproj]
------
Dockerfile:12
--------------------
  10 |     # Copy the project file and restore dependencies
  11 |     COPY PinfoBackend.csproj ./
  12 | >>> RUN dotnet restore "PinfoBackend.csproj" --disable-parallel
  13 |     
  14 |     # Copy all the source code and build the project
--------------------
ERROR: failed to solve: process "/bin/sh -c dotnet restore "PinfoBackend.csproj" --disable-parallel" did not complete successfully: exit code: 1
Error: Process completed with exit code 1.

I have no idea what the message task is and I don’t really find anything about that.

2

After checking the issue, we can fix the issue by removing below settings in appsettings.json.

                    ,
  "Kestrel": {
    "Endpoints": {
      "Http": {
        "Url": "http://0.0.0.0:5000"
      }
    }
  }

Here is the correct sample code.

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*"
}

I searched github repo by the project name and found yours, here is my github actions history.

And test in my side, it works properly.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật