Error MSB4166: Child node "2" exited prematurely. Shutting down

doraimon 5 Reputation points
2023-12-18T07:36:57.7366667+00:00

I am using MessagePack to create executables.

However, I want to create one big mpc.exe file that includes the dotnet assembly.

That file is created by building the MessagePack.Generator.

So I used ILRepack, and it outputs an error message like the one in the title.

I am building a project with the following path

https://github.com/MessagePack-CSharp/*MessagePack-CSharp*

Following advice from the web, I added the '-nodeReuse:false' option to the build command for the dotnet.yml file in MessagePack.

from : - script: dotnet build -t:build,pack --no-restore -c $(BuildConfiguration) /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog -v:d"

to : - script: dotnet build -t:build,pack --no-restore -c -nodeReuse:false $(BuildConfiguration) /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog -v:d"

But the build still fails.

The project's csproj file we're trying to build looks like this

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <AssemblyName>mpc</AssemblyName>
    <OutputType>Exe</OutputType>
    <TargetFrameworks>net6.0;net7.0</TargetFrameworks>
    <ToolCommandName>mpc</ToolCommandName>
    <RollForward>Major</RollForward>
    <CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
    <IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
    <IncludeGetResolvedSDKReferences>true</IncludeGetResolvedSDKReferences>
    <PublishSingleFile>true</PublishSingleFile>
    <SelfContained>true</SelfContained>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <PublishTrimmed>true</PublishTrimmed>

    <!-- NuGet Info -->
    <PackageId>MessagePack.Generator</PackageId>
    <Title>MessagePack Code Generator</Title>
    <Description>MessagePack standalone code generator.</Description>
    <PackageTags>MsgPack;MessagePack;Serialization;Formatter;Serializer;Unity;Xamarin</PackageTags>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="ConsoleAppFramework" />
    <PackageReference Include="ILRepack" />
    <PackageReference Include="ILRepack.MSBuild.Task" />
    <PackageReference Include="Microsoft.Build.Locator" />
    <PackageReference Include="Microsoft.Build.Framework" />
    <PackageReference Include="Microsoft.Build" />
    <PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\MessagePack.GeneratorCore\MessagePack.GeneratorCore.csproj" />
  </ItemGroup>

  <Target Name="ILRepack" AfterTargets="Build">
    <PropertyGroup>
      <WorkingDirectory>$(MSBuildThisFileDirectory)bin\$(Configuration)\$(TargetFramework)</WorkingDirectory>
    </PropertyGroup>
    <ItemGroup>
      <InputAssemblies Include="@(ReferencePathWithRefAssemblies)" />
    </ItemGroup>
    <Message Text="MERGING: @(InputAssemblies->'%(Filename)') into $(OutputAssembly)" Importance="High" />
    <ILRepack OutputType="$(OutputType)" MainAssembly="$(OutputPath)\$(AssemblyName).dll" OutputAssembly="$(AssemblyName).exe" InputAssemblies="@(InputAssemblies)" WorkingDirectory="$(OutputPath)" />
  </Target>

</Project>

What can I do now?

Community Center | Not monitored
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.