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

查看:252
本文介绍了.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天全站免登陆