在 Mac 或 Windows 上运行 .NET Core 控制台应用程序 [英] Running a .NET Core Console Application on Mac or Windows
问题描述
我已经创建了一个 .NET Core 控制台应用程序.我想构建应用程序,以便我可以在 Windows 或 MacOS 上执行它,而无需在机器上安装 dotnet 核心.所以我需要例如对于 Windows,一个 exe.
I've created a .NET Core console application. I want to build the app so that I can execute it on Windows or MacOS without dotnet core being installed on the machine. So I need e.g. for windows an exe.
我已阅读 https://docs.microsoft.com/de-de/dotnet/articles/core/tools/dotnet-publish,我知道如何为不同平台编译应用程序.
I've read https://docs.microsoft.com/de-de/dotnet/articles/core/tools/dotnet-publish and I know how to compile the application for the different platform(s).
但是没有创建可执行文件.我在这里缺少什么以及如何实现我的目标?
But no executable gets created. What am I missing here and how do I accomplish my goal?
推荐答案
您需要的是创建一个 自包含应用程序.该链接解释了如何修改您的 project.json 来做到这一点.
What you need is to create a self-contained application. The link explains how exactly to modify your project.json to do that.
另请注意,虽然自包含应用程序不依赖于 .Net Core,但它可能具有其他依赖项.特别是在 OSX 上,我相信您需要从自制软件安装特定版本的 openssl.
Also note that while a self-contained application does not have a dependency on .Net Core, it may have other dependencies. Specifically on OSX, I believe you will need to install a specific version of openssl from homebrew.
这篇关于在 Mac 或 Windows 上运行 .NET Core 控制台应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!