C# 如何创建控制台应用程序的 exe

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12889269/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 00:50:23  来源:igfitidea点击:

How to create exe of a console application

c#winforms

提问by being fab

How can we create the exe for a console forms application ?

我们如何为控制台表单应用程序创建 exe?

采纳答案by John Woo

an EXEfile is created as long as you build the project. you can usually find this on the debug folder of you project.

EXE只要您构建项目,就会创建一个文件。您通常可以在项目的调试文件夹中找到它。

C:\Users\username\Documents\Visual Studio 2012\Projects\ProjectName\bin\Debug

回答by edwinmiller

The following steps are necessary to create .exe i.e. executable files which are as 1) Open visual studio framework 2) Then, create a new project or application 3) Build or execute your application by pressing F5

创建 .exe 即可执行文件需要以下步骤 1) 打开 Visual Studio 框架 2) 然后,创建一个新项目或应用程序 3) 按 F5 构建或执行您的应用程序

回答by King Midas

Normally, the exe can be found in the debug folder, as suggested previously, but not in the release folder, that is disabled by default in my configuration. If you want to activate the release folder, you can do this: BUILD->Batch Build And activate the "build" checkbox in the release configuration. When you click the build button, the exe with some dependencies will be generated. Now you can copy and use it.

通常,exe 可以在 debug 文件夹中找到,如之前所建议的,但不在 release 文件夹中,在我的配置中默认禁用。如果要激活发布文件夹,可以这样做:BUILD->Batch Build 并激活发布配置中的“构建”复选框。当您单击构建按钮时,将生成具有一些依赖项的 exe。现在您可以复制和使用它。

回答by Saif Asad

For .net core 2.1 console application, the following approaches worked for me:

对于 .net core 2.1 控制台应用程序,以下方法对我有用:

1 - from CLI(after building the application and navigating to debug or release folders based on the build type specified):

1 -来自 CLI(在构建应用程序并根据指定的构建类型导航到调试或发布文件夹之后):

dotnet appName.dll

2 - from Visual Studio

2 - 来自Visual Studio

R.C solution and click publish
'Target location' -> 'configure' ->
   'Deployment Mode' = 'Self-Contained'
   'Target Runtime' = 'win-x64 or win-x86 depending on the OS'

References:

参考:

For an in depth explanation of all the deployment options available for .net core applications, checkout the following articles:

有关 .net 核心应用程序可用的所有部署选项的深入说明,请查看以下文章:

回答by Yodacheese

For .NET Core 2.2 you can publish the application and set the target to be a self-contained executable.

对于 .NET Core 2.2,您可以发布应用程序并将目标设置为自包含的可执行文件。

In Visual Studio right click your console application project. Select publish to folder and set the profile settings like so:

在 Visual Studio 中,右键单击您的控制台应用程序项目。选择发布到文件夹并像这样设置配置文件设置:

Visual Studio Publish Menu

Visual Studio 发布菜单

You'll find your compiled code with the .exe in the publish folder.

您将在发布文件夹中找到带有 .exe 的编译代码。