.NET desktop app for MacOS

I'm developing a desktop application in C# and Avalonia for my company. I have quite good experience with .NET development but I've never created an app for MacOS so I need some advises and best practices.

When I run the app on my Mac, it works properly, but I'm not able to run it on different device. The solutions contains multiple project and I compile it with this command:

dotnet publish \                          
  -p:TargetFramework=net7.0 \
  -p:RuntimeIdentifier=osx-arm64 \
  -p:SelfContained=true \
  -p:PublishSingleFile=true \
  -p:IncludeNativeLibrariesForSelfExtract=true \
  -p:PublishTrimmed=true \
  -p:PublishReadyToRun=true \
  -p:EnableCompressionInSingleFile=true \
  -p:DebugType=embedded \
  -p:ServerGarbageCollection=true \
  --output dist

It creates folder with one executable and multiple .dylib files. I'm not really sure how to create .app bundle from this folder, I've found app called Platypus and it works quite well, but I will appreciate any advice on this.

In addition, the app needs folder with templates and config files (can be read-only) and creates quite high amount of temporary files which could use a temporary folder. Where should I put these? Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) returns /Users/username/.config, is it a good place for the temp folder?

Until now I've tried to put these things to the .app bundle via Platypus, but after running it on another device, an unhandled exception occurred due to read-only permissions for the tmp folder created by the app. For testing purposes I'd tried to setup Run with root privileges in Platypus and the exception didn't occur. But still, the main window of the app didn't show even when on my device it works well.

I will appreciate any ideas or advices on this issue. Also if there is any tutorial for beginner MacOS developers (I don't need to learn Swift right now), please let me know.

DevForums is primarily focused on Apple APIs and tools. There aren’t a lot of folks here with expertise in .NET here. If no one else chimes in, my advice is that you explore the support resources for that tooling.

… returns /Users/username/.config, is it a good place for the temp folder?

No. The canonical way to locate the temporary directory on Apple platforms is with the temporaryDirectory property of FileManager. For a non-sandboxed macOS app that returns a path like /var/folders/n_/p9vcphfj2l7c7fmh0ct2f70w0000gp/T.

As to how you get that path with .NET, I don’t have any expertise to share on that front.

Until now I've tried to put these things to the .app bundle via Platypus

Don’t do that. It will cause problems down the line. See Separate read-only and read/write content in “Embedding nonstandard code structures in a bundle”.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

.NET desktop app for MacOS
 
 
Q