dotnet / sdk-container-builds

Libraries and build tooling to create container images from .NET projects using MSBuild
https://learn.microsoft.com/en-us/dotnet/core/docker/publish-as-container
MIT License
180 stars 39 forks source link

Dotnet publish container regression in 8.0.400 #587

Closed Vhab closed 2 months ago

Vhab commented 2 months ago

We're still gathering more information, but would like to already start the conversation and see if we're the only one affected.

Since yesterday's release of .NET 8.0.400, our CI pipelines are unable to build containerized versions of our application.

The error we're seeing is as follows:

MSBUILD : error MSB4166: Child node "2" exited prematurely. Shutting down. Diagnostic information may be found in files in "/tmp/MSBuildTemproot/" and will be named MSBuild_*.failure.txt. This location can be changed by setting the MSBUILDDEBUGPATH environment variable to a different directory.
MSBUILD : error MSB4166: /tmp/MSBuildTemproot/MSBuild_pid-950_544b456e882e4927b4070035db4a49df.failure.txt:
MSBUILD : error MSB4166: UNHANDLED EXCEPTIONS FROM PROCESS 950:
MSBUILD : error MSB4166: =====================
MSBUILD : error MSB4166: 08/13/2024 21:05:27
MSBUILD : error MSB4166: System.ArgumentNullException: Value cannot be null. (Parameter 'value')
MSBUILD : error MSB4166:    at System.ArgumentNullException.Throw(String paramName)
MSBUILD : error MSB4166:    at System.IO.BinaryWriter.Write(String value)
MSBUILD : error MSB4166:    at Microsoft.Build.Framework.TelemetryEventArgs.WriteToStream(BinaryWriter writer)
MSBUILD : error MSB4166:    at Microsoft.Build.Shared.LogMessagePacketBase.WriteToStream(ITranslator translator)
MSBUILD : error MSB4166:    at Microsoft.Build.BackEnd.NodeEndpointOutOfProcBase.RunReadLoop(Stream localReadPipe, Stream localWritePipe, ConcurrentQueue`1 localPacketQueue, AutoResetEvent localPacketAvailable, AutoResetEvent localTerminatePacketPump)
MSBUILD : error MSB4166: ===================

The logfiles mentioned in the error don't contain any additional information not already printed in the log above.

Our build command looks as following and is being executed on ubuntu:

        dotnet publish \
          "${{ container.projectPath }}" \
          --os linux \
          --arch x64 \
          -c Release \
          "/p:ContainerRepository=${{ container.containerName }}" \
          "/p:ContainerImageTag=${{ parameters.version }}" \
          "/p:ContainerArchiveOutputPath=$(Build.ArtifactStagingDirectory)/${{ parameters.artifactsName }}/${{ container.containerName }}-${{ parameters.version }}.tgz" \
          /t:PublishContainer

We're not seeing the same error with dotnet build, and not with any non-container dotnet publish steps we have.

I have since been able to reproduce this on Windows 11 + .NET SDK 8.0.400 as well, with the simplified command: dotnet publish /t:PublishContainer myproject.csproj

Will try to create a minimal .csproj to reproduce.

Vhab commented 2 months ago

I've setup a production case here: https://github.com/Vhab/DotnetContainerPublish8-0-400-Repro

It seems to trigger when multiple project dependencies are involved, and somewhere in the tree they converge to the same dependency. At least that's my impression from my limited testing.

baronfel commented 2 months ago

Commenting here for completeness but this is a hard crash in the SDK that we will be releasing a 401 hotfix for in the next day. Further details on the SDK issue at https://github.com/dotnet/sdk/issues/42719#issuecomment-2288899273.