-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
App published for net6.0-macos doesn't work in sandbox #80016
Comments
Tagging subscribers to this area: @agocke, @vitek-karas, @VSadov Issue DetailsDescriptionThe command See discussion Reproduction StepsI am trying to publish an Mac app for code signing. I have tried with PublishReadyToRun , which caused the error as in: Now I am trying to use publish single file with this very simple setup: true and command dotnet publish -c release -r osx-x64,which caused the error below: /usr/local/share/dotnet/sdk/7.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(104,5): error NETSDK1098: Applications published to a single-file are required to use the application host. You must either set PublishSingleFile to false or set UseAppHost to true. /usr/local/share/dotnet/sdk/7.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(904,5): error MSB4018: The "GenerateBundle" task failed unexpectedly. Expected behaviorA single file bundle for macos is generated. Actual behaviorError reported: /usr/local/share/dotnet/sdk/7.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(904,5): error MSB4018: The "GenerateBundle" task failed unexpectedly. Regression?No response Known WorkaroundsNo response ConfigurationNo response Other informationNo response
|
Does .NET 6 actually support |
Yes. OS-Specific TFM docs: https://learn.microsoft.com/en-us/dotnet/standard/frameworks#net-5-os-specific-tfms Basically, <TargetFramework>net6.0</TargetFramework>
<TargetPlatformIdentifier>macos</TargetPlatformIdentifier> By setting TPI, |
Mono currently doesn't support
|
If this is the ultimate goal, then I think you can use Apple's Application Bundle (.app) and
I have tested it with net6.0-macos and net7.0-macos. |
@am11 I am sorry I haven't made the whole picture clear. The eventual goal is code signing with sandbox enabled in entitlement file. Sandbox is mandatory for distribution in Mac App store. I have found out standard publish function integrated in Visual Studio for Mac actually works fine when sandbox is disabled. But when it is enabled, signed app would crash. Here is the link to my post to apple support: https://developer.apple.com/forums/thread/722313 I did some search and found out that when running in sandbox, dylib must be put under That is why it is necessary to use single file publish.
|
How does it crash? I applied this patch in --- a/LayerMixer.csproj
+++ b/LayerMixer.csproj
@@ -21,7 +21,9 @@
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-<PublishSingleFile>true</PublishSingleFile>
+ <ArchiveOnBuild>true</ArchiveOnBuild>
+ <CodesignKey>MyAppSignCert</CodesignKey>
+ <CodesignEntitlements>Platforms/macos/Entitlements.plist</CodesignEntitlements>
<!--
<PublishReadyToRun>true</PublishReadyToRun>
--> (where added a file: <?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.app-sandbox</key>
<true/>
<key>com.apple.application-identifier</key>
<string>com.abc.def</string>
<key>com.apple.security.cs.allow-jit</key>
<true/>
</dict>
</plist> then to publish, used:
it produced a .pkg installer. The whole process is described for iOS (.ipa): https://learn.microsoft.com/en-us/dotnet/maui/ios/deployment/overview?view=net-maui-7.0 but not for macOS exclusively, so I improvised a bit. If you run that .pkg installer as described and launch the installed app, does it still crash? All However, I checked with |
I repeated with your config exactly. An app bundle was created together with the pkg. I launched the app directly and following error was popped up. I used actual apple developer certificate for signing:
I used a Mac air M1.
|
Interesting. to troubleshoot:
according to google, this is happening after some recent updates. e.g. https://developer.apple.com/forums/thread/722313. |
Support for true single-file with Mono is currently not in the plan (at least for 8). But it seems that this issues is not exactly about that. I changed the title to reflect the discussion of how to run the app in sandbox. I changed the area to mono since it probably belongs in there more than current single-file - Hopefully somebody from mono side will know who to ask specifically. |
Followed your steps:
Thanks a lot for spending time on this issue. This dotnet app we are working on is a rebuild of our legacy Electron app, which hit some performance walls, not for the UI part but for the underlying computation heavy tasks. We decide to evaluate SwiftUI instead for Mac and put dotnet macos version on hold for a while. Thanks again. |
cc @akoeplinger @kotlarmilos - something we should look into. Based on last comment from @lanyusan, seems it is not blocking any more. Moving to 9.0.0 milestone. |
Description
The command
dotnet publish -c release -r osx-x64 -p:UseAppHost=true -p:PublishSingleFile=true
won't work if target is net6.0-macos.See
#79948
for earlier discussions.
Reproduction Steps
I am trying to publish an Mac app for code signing.
I have tried with PublishReadyToRun , which caused the error as in:
#79947
Now I am trying to use publish single file with this very simple setup:
target framework
net6.0-macos
, and commanddotnet publish -c release -r osx-x64
,which caused the error below:
So I ran this command dotnet publish -c release -r osx-x64 -p:UseAppHost=true, which caused this error:
Expected behavior
A single file bundle for macos is generated.
Actual behavior
Error reported:
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: