【问题标题】:Creating .app bundle on Mac from self contained .net core console app从自包含的 .net 核心控制台应用程序在 Mac 上创建 .app 包
【发布时间】:2021-02-03 15:16:30
【问题描述】:

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

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

有没有一种简单的方法可以直接从 Visual Studio for 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>

知道我该怎么做吗?谢谢

【问题讨论】:

  • 只是一个想法,你可以在这里使用single file publish
  • 这对我的目的很有效@PavelAnikhouski,如果你想写一个答案以获得一些分数,请随意

标签: c# macos visual-studio .net-core console


【解决方案1】:

.NET Core 3.x 引入了single file publish,它已经允许您生成单个二进制文件。基本上,您可以将PublishSingleFile&gt;true&lt;/PublishSingleFile&gt; 属性添加到您的.csproj 文件或使用-p:PublishSingleFile=true 和dotnet pusblish CLI 命令。

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

【讨论】:

    猜你喜欢
    • 2019-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多