从自包含的 .net 核心控制台应用程序在 Mac 上创建 .app 包

Creating .app bundle on Mac from self contained .net core console app

我正在尝试弄清楚如何将我在 C# + .NET core 3.1 中制作的工具作为 Mac 的易于 运行.app 文件部署给我的同事。该应用程序已制作完成,我已将其发布为一个独立的应用程序,这样他们就不需要安装 .NET 核心,但我在将 120 多个文件放入单个 .app 文件时遇到了问题。

我尝试使用 Info.plist 手动执行此操作,但是当我尝试将其作为 .app 运行 时应用程序“意外崩溃”(在 运行ning 时工作正常只是可执行文件)。

是否有直接从 Visual Studio 为 Mac 或什至从命令行执行此操作的简单方法?

这是我进行的手动尝试的文件结构:

MyApp.app
    Contents
        Info.plist
        MacOS
            MyAppExecutable
            (.net core files - DLLs, dylibs, etc)
        Resources
            icon.icms

这是我的 Info.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>CFBundleGetInfoString</key>
  <string>MyApp</string>
  <key>CFBundleExecutable</key>
  <string>MyAppExecutable</string>
  <key>CFBundleIdentifier</key>
  <string>com.Random-app-developer.www</string>
  <key>CFBundleName</key>
  <string>MyApp</string>
  <key>CFBundleIconFile</key>
  <string>icon.icns</string>
  <key>CFBundleShortVersionString</key>
  <string>0.01</string>
  <key>CFBundleInfoDictionaryVersion</key>
  <string>6.0</string>
  <key>CFBundlePackageType</key>
  <string>APPL</string>
  <key>IFMajorVersion</key>
  <integer>0</integer>
  <key>IFMinorVersion</key>
  <integer>1</integer>
</dict>
</plist>

知道我该怎么做吗?谢谢

.NET Core 3.x 引入了 single file publish,它已经允许您生成单个二进制文件。基本上,您只需将 PublishSingleFile>true</PublishSingleFile> 属性 添加到 .csproj 文件或使用 -p:PublishSingleFile=truedotnet pusblish CLI 命令。

可以找到包含一些内部细节的设计文档here