PublishSingleFile Failure Must Specify Host Binary
See original GitHub issueHello, 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:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top GitHub Comments
@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.
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!