Visual Studio 2017 和缺少的 EXE 文件

Visual Studio 2017 and a missing EXE file(Visual Studio 2017 和缺少的 EXE 文件)
本文介绍了Visual Studio 2017 和缺少的 EXE 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(我使用的是 Visual Studio 2017.)

我启动了一个小型控制台应用程序.

解决方案

更新答案:

早在 2017 年编写此答案时,.NET Core 仅输出 dll 文件,此后情况发生了变化.现在可以在应用程序的 csproj 中使用此属性来实现:

<OutputType>Exe</OutputType>

还有其他部署方法,例如 single-file部署.


原答案:

没有 exe 文件,因为您创建了一个 .NET Core 应用程序.

你有两个选择:

  1. 如果您需要 EXE,则需要以 .NET Framework 为目标.
  2. 如果您不想更改代码,则需要在服务器上安装 .NET Core 并在命令行上运行 dotnet pathToDll

(I am using Visual Studio 2017.)

I started a small console application. A Discord C# bot. So I always launched this program with Visual Studio. After finishing it, I wanted to put the .exe file on a server, to keep this bot stay online all day long.

In the directory, there isn't any .exe file.

So I started the application again and saw this console is opened from a different path:

"C:Program Filesdotnet" and this .exe is called "dotnet.exe"

When I want to start this .exe file manually, it closes instantly (maybe because of the missing line of code Console.ReadLine(); I don't know).

What should I change in Visual Studios settings to have an .exe file in my correct directory for my console application?

The attached picture shows my bin directory, where the .exe file should normally be. There is a .dll file, but I need the .exe file...

解决方案

Updated answer:

When this answer was written, back in 2017, .NET Core only output dll files, this has since changed. This can now be achieved with this property in the application's csproj:

<OutputType>Exe</OutputType>

There are also additional deployment methods like the single-file deployment.


Original answer:

There is no exe file because you created a .NET Core application.

You have two options:

  1. If you want an EXE, you need to target the .NET Framework.
  2. If you don't want to change your code, then you need to install .NET Core on the server and run dotnet pathToDll on a command line

这篇关于Visual Studio 2017 和缺少的 EXE 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)