问题描述
(我使用的是 Visual Studio 2017.)
我启动了一个小型控制台应用程序.
更新答案:
早在 2017 年编写此答案时,.NET Core 仅输出 dll 文件,此后情况发生了变化.现在可以在应用程序的 csproj 中使用此属性来实现:
<OutputType>Exe</OutputType>
还有其他部署方法,例如 single-file部署.
原答案:
没有 exe 文件,因为您创建了一个 .NET Core 应用程序.
你有两个选择:
- 如果您需要 EXE,则需要以 .NET Framework 为目标.
- 如果您不想更改代码,则需要在服务器上安装 .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:
- If you want an EXE, you need to target the .NET Framework.
- 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 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!