To narrow down some problems with a larger project, I have created a simple .NET 9 Console test from the template in Visual Studio 2022 on a Windows machine (the simple "Hello World" one). I then configured a Publish profile to generate a self-contained set of files for deployment on "osx-arm64" target. Everything is generated fine. The project is named MacDeploy, and so is the generated appHost.
I copied the published files (~84Mb) to the macOS machine (macOS 15.3.2). There, I added execute attributes to the "MacDeploy" file (which is the appHost).
If I now run "dotnet MacDeploy.dll" in Terminal, I get "Hello, World!" there - all is fine. But if I attempt to run just "./MacDeploy", all I get is
zsh: killed ./MacDeploy
I tried running the appHost with and without MacDeploy.runtimeconfig.json in the directory; this made no difference.
I am having the same problem with the main project, so it is not a problem of a particular project. It may be a problem with the system, but I don't have other macs to check. The Console tool of macOS does not show any errors in the logs, so I am at a loss. Where can I look for any error information, or what may this appHost be missing?
Could it be that I must sign the app and add entitlements during signing? This Microsoft article mentions that the entitlements should be present, but it does not provide instructions on adding them, and the language is a bit vague.
Indeed, it turned out to be missing entitlements. I fixed the problem using the following steps:
codesign --entitlements entitlements.plist --options runtime --sign "Developer ID Application: Callback Technologies, Inc. (our-team-id-here)" ./MacDeploy
If you get "Code object was not signed at all" error (this can happen with a project with dependencies and extra libraries", adding "--deep" to the above command line helps.
The entitlements file is
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
</dict>
</plist>