Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'singlefilehost' does not specify a 'PublishFolderType' metadata #22084

Open
ztl8702 opened this issue Jan 31, 2025 · 2 comments
Open

'singlefilehost' does not specify a 'PublishFolderType' metadata #22084

ztl8702 opened this issue Jan 31, 2025 · 2 comments

Comments

@ztl8702
Copy link

ztl8702 commented Jan 31, 2025

Apple platform

macOS

Framework version

net9.0-*

Affected platform version

.NET 9.0.102

Description

While attempting to publishing a self-contained single executable file, targeting net9.0-macos, the MSBuild publish target fails with:

    /usr/local/share/dotnet/packs/Microsoft.macOS.Sdk.net9.0_15.2/15.2.9173/targets/Xamarin.Shared.Sdk.targets(1903,3): warning : The file '/Users/ztl8702/Documents/ScratchProjects/SignedApp/obj/Release/net9.0-macos/osx-x64/singlefilehost' does not specify a 'PublishFolderType' metadata, and a default value could not be calculated. The file will not be copied to the app bundle.
    /usr/local/share/dotnet/sdk/9.0.102/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(1116,5): error MSB4018: 
      The "GenerateBundle" task failed unexpectedly.
      System.ArgumentException: Invalid input specification: Must specify the host binary
         at Microsoft.NET.HostModel.Bundle.Bundler.GenerateBundle(IReadOnlyList`1 fileSpecs)
         at Microsoft.NET.Build.Tasks.GenerateBundle.ExecuteCore()
         at Microsoft.NET.Build.Tasks.TaskBase.Execute()
         at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
         at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(TaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, Ta
      skHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)

Steps to Reproduce

repro.zip

  1. Unzip the above ZIP
  2. Run dotnet publish -c Release -r osx-x64 -p:PublishSingleFile=true -p:UseAppHost=true

Did you find any workaround?

Not yet.

Build logs

msbuild.binlog.zip

@snechaev
Copy link
Contributor

Your test project is typical macos app with the UI. It can't be built as a single file due to macOS limitations. The macOS application is typically represented by so called application bundle, which is a folder with the .app extension.
So, net-macos will produce such an app bundle on build (no need to call publish at all) and the PublishSingleFile=true just not supported (and even the net sdk will somehow support it, such an app will not run on macOS).

So, just run dotnet build -c release then grab app bundle from the /bin/Relese folder. Additionally, this will produce multi-platform bundle, so it will work both on intel-based and arm-based mac.

@ztl8702
Copy link
Author

ztl8702 commented Jan 31, 2025

Thanks for the clarification. Feel free to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants