.NetCore for Mac - 发布到原生 Mac 应用程序/二进制文件? [英] .NetCore for Mac - Publish to Native Mac App/Binary?

查看:33
本文介绍了.NetCore for Mac - 发布到原生 Mac 应用程序/二进制文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索了很长时间,似乎无法找到这个问题的答案.在 SO 上只找到了两个问题/答案,但他们仍然没有回答这个问题(https://stackoverflow.com/search?q=netcore+publish+mac+app).

I've been searching for quite some time now, and can't seem to find an answer to this problem. Found only two questions/answers on SO and they still don't answer this question (https://stackoverflow.com/search?q=netcore+publish+mac+app).

我正在 Mac 上使用 DotNetCore,使用 Visual Studio 作为 IDE.该应用程序是一个控制台应用程序,而不是一个 ASP.Net 应用程序,它是 C# 中的简单Hello World"应用程序:

I'm working with DotNetCore on Mac, using Visual Studio as the IDE. The app is a Console App, not an ASP.Net app, simple "Hello World" app in C#:

...
Console.Writeline("Hello World");
...

问题来了……要运行该应用程序,我知道我可以使用dotnet"命令来运行它.我正在尝试构建/发布应用程序,就像您在 Windows 中通常通过创建 .exe 文件所做的那样,但现在在 Mac 上通过创建本机二进制文件.

So here's the question... To run the app, I know I can use the "dotnet" command to run it. I'm trying to build/publish the app, as you normally would do in Windows by creating an .exe file, but now on Mac by creating a native binary file.

我找到了关于如何执行此操作的零文档,并将应用程序部署为一个独立的应用程序,该应用程序可以独立运行而无需使用dotnet"命令调用程序.也许我找错了地方,但在 Microsoft 的文档中什至没有找到任何内容,它们都指向在 .NetCore 上构建 ASP.Net 应用程序的文档.

I have found zero documentation on how to do this, and deploy the application as a self contained app that can run independently without having to call the program using the "dotnet" command. Maybe I'm looking in the wrong places but haven't even found anything on Microsoft's documentation, they all point to documentation for building ASP.Net apps on .NetCore.

有什么建议吗?

推荐答案

通过查看dotnet publish"选项找到答案:

Found the answer by looking at the "dotnet publish" options:

dotnet publish -c Release --self-contained -r osx.10.13-x64

其中 --self-contained 包括所有必需的库,-r 指定运行时目标.

Where --self-contained includes all required libraries, and -r specifies the runtime target.

这篇关于.NetCore for Mac - 发布到原生 Mac 应用程序/二进制文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆