0

我在 .NET Core 3.1.200 中有一个带有此 PublishProfile 的应用程序,用于定位 osx-x64:

<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121. 
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <PublishProtocol>FileSystem</PublishProtocol>
    <Configuration>Release</Configuration>
    <Platform>Any CPU</Platform>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <PublishDir>bin\Release\netcoreapp3.1\publish\</PublishDir>
    <RuntimeIdentifier>osx-x64</RuntimeIdentifier>
    <SelfContained>true</SelfContained>
    <PublishSingleFile>True</PublishSingleFile>
    <PublishReadyToRun>False</PublishReadyToRun>
    <PublishTrimmed>False</PublishTrimmed>
  </PropertyGroup>
</Project>

我已经运行dotnet publish myapp.cproj /p:PublishProfile=profile.xml,最后 /publish 文件夹包含一个文件“myapp”(这是正确的,因为 PublishSingleFile=True)。

但它没有扩展名。如何在 MacOS 上运行它?

编辑:我发现我可以简单地从终端运行它./myapp。但是如何通过双击Finder来运行它呢?目前,它显示:

在此处输入图像描述

4

1 回答 1

1

基于 .NET Core 的应用程序(带有用户界面)必须打包为应用程序包,以便 Finder 正确识别。

这是一个漫长的过程,但是 Avalonia 的家伙写了一篇文章,详细的步骤,

https://docs.avaloniaui.net/docs/distribution-publishing/macos

您可以使用dotnet-bundle工具来自动化其中的大部分。

于 2020-04-13T16:28:38.970 回答