question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PublishSingleFile Failure Must Specify Host Binary

See original GitHub issue

Hello, I’m working on a .NET 3.1 serverless application and am hoping to significantly reduce the size of the program uploaded to aws lambda using PublishSingleFile. I have been successful in using all the other optimization features such as; publish ready to run and trimming. However, when publish single file is enabled on both my local host (run time identifier = osx.10.13-x64) and remote gitlab build machine (run time identifier = linux-x64) the following error occurs in both scenarios when publishing.

/usr/local/share/dotnet/sdk/3.1.200/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(881,5): error MSB4018: The “GenerateBundle” task failed unexpectedly. [/Users/toddzmijewski/Projects/Classifieds/src/Classifieds.Chat/Classifieds.Chat.csproj] /usr/local/share/dotnet/sdk/3.1.200/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(881,5): error MSB4018: System.ArgumentException: Invalid input specification: Must specify the host binary [/Users/toddzmijewski/Projects/Classifieds/src/Classifieds.Chat/Classifieds.Chat.csproj] /usr/local/share/dotnet/sdk/3.1.200/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(881,5): error MSB4018: at Microsoft.NET.HostModel.Bundle.Bundler.GenerateBundle(IReadOnlyList`1 fileSpecs) [/Users/username/Projects/Classifieds/src/Classifieds.Chat/Classifieds.Chat.csproj] /usr/local/share/dotnet/sdk/3.1.200/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(881,5): error MSB4018: at Microsoft.NET.Build.Tasks.GenerateBundle.ExecuteCore() [/Users/usernamei/Projects/Classifieds/src/Classifieds.Chat/Classifieds.Chat.csproj] /usr/local/share/dotnet/sdk/3.1.200/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(881,5): error MSB4018: at Microsoft.NET.Build.Tasks.TaskBase.Execute() [/Users/username/Projects/Classifieds/src/Classifieds.Chat/Classifieds.Chat.csproj] /usr/local/share/dotnet/sdk/3.1.200/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(881,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [/Users/username/Projects/Classifieds/src/Classifieds.Chat/Classifieds.Chat.csproj] /usr/local/share/dotnet/sdk/3.1.200/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(881,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [/Users/usernamei/Projects/Classifieds/src/Classifieds.Chat/Classifieds.Chat.csproj]

I managed to track down this issue which seems like it might be semi-related.

https://github.com/dotnet/runtime/issues/3739

Here is my project file.

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

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <DockerComposeProjectPath>../../docker-compose.dcproj</DockerComposeProjectPath>
    <UserSecretsId>a7034702-8808-492e-ac99-2cb8f6de5986</UserSecretsId>
    <!-- <RuntimeIdentifier>linux-x64</RuntimeIdentifier> -->
    <RuntimeIdentifier>osx.10.13-x64</RuntimeIdentifier>
    <PublishReadyToRun>true</PublishReadyToRun>
    <PublishTrimmed>true</PublishTrimmed>
    <PublishSingleFile>true</PublishSingleFile>
    <AWSProjectType>Lambda</AWSProjectType>
    <OutputType>Exe</OutputType>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Serilog" Version="2.9.0" />
    <PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
    <PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
    <PackageReference Include="Amazon.Lambda.AspNetCoreServer" Version="5.0.0" />
    <PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
    <PackageReference Include="Amazon.Lambda.Serialization.Json" Version="1.7.0" />
    <PackageReference Include="CassandraCSharpDriver" Version="3.14.0" />
    <PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.3" />
    <PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
    <PackageReference Include="AWSSDK.ApiGatewayManagementApi" Version="3.3.101.103" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="..\Classifieds.Shared\Models\ChatMessage.cs;..\Classifieds.Shared\Models\ChatConnection.cs;..\Classifieds.Shared\Models\ChatConversation.cs;..\Classifieds.Shared\Models\PublicUserProfile.cs;;..\Classifieds.Shared\Services\AuthApi.cs;">
        <Link>_Inlined\Classifieds.Shared\%(RecursiveDir)%(Filename)%(Extension)</Link>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <None Remove="bootstrap" />
  </ItemGroup>
  <ItemGroup>
    <None Include="AmazonRootCA1.pem" CopyToOutputDirectory="PreserveNewest" />
  </ItemGroup>
  <ItemGroup>
    <Folder Include="Repositories\" />
    <Folder Include="Mappings\" />
    <Folder Include="Controllers\" />
    <Folder Include="Models\" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="bootstrap">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
</Project>

This is the build command which I’m running.

dotnet publish src/Classifieds.Chat/Classifieds.Chat.csproj --self-contained true --runtime osx.10.13-x64 -p:AssemblyName=bootstrap;PublishReadyToRunShowWarning=true

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
agockecommented, Nov 11, 2021

@eduherminio It looks like you’re trying to use single-file with NativeAOT, is that correct? That should be unnecessary. NativeAOT always publishes a single-file.

0reactions
eduherminiocommented, Nov 11, 2021

I see, that’s why. Yeah, without single-file it just works (and produces a single file, as you mention). It probably shouldn’t break though, but I leave that up to you if you consider that’s worth having a dedicated issue 😃 Thanks @agocke!

Read more comments on GitHub >

github_iconTop Results From Across the Web

PublishSingleFile Failure Must Specify Host Binary #11782
Hello, I'm working on a .NET 3.1 serverless application and am hoping to significantly reduce the size of the program uploaded to aws...
Read more >
Create a single file for application deployment - .NET
Bundling all application-dependent files into a single binary ... <PublishSingleFile> should be set in the project file to enable file ...
Read more >
How can I get my .NET Core 3 single file app to find ...
The root of the issue is that the PublishSingleFile binary is unzipped and run from a temp directory. In the case of this...
Read more >
dotnet publish command - .NET CLI
dotnet publish compiles the application, reads through its dependencies specified in the project file, and publishes the resulting set of ...
Read more >
c# - Configuring NLOG with PublishSingleFile option set
After enabling the stdout.log file I can see the reason. Unhandled exception. System.IO.FileNotFoundException: Failed to load NLog ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found