为什么在编译 .NET Core 控制台应用程序时,我们最终会得到 dll 和 exe 文件? [英] Why when compiling .NET Core console application we end up with both dll and exe files?

查看:36
本文介绍了为什么在编译 .NET Core 控制台应用程序时,我们最终会得到 dll 和 exe 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到在编译 .NET Core 控制台应用程序时,在 Windows 上创建了具有项目名称的 dll 和 exe 文件.这是为什么?在完整的 .Net 框架中,只会创建 exe 文件.

I have noticed that both dll and exe files with the name of the project are created on Windows when compiling a .NET Core console application. Why is that? In full .Net framework only the exe file would be created.

推荐答案

在 .Net Core 3.0 之前,只创建了 dll(尽管您仍然可以执行平台的单个文件构建-依赖).在这些情况下,您必须使用命令 dotnet MyProject.dll 来启动您的程序.

Prior to .Net Core 3.0, only the dll was created (although you could still do a single file build that was platform-dependent). In these cases you had to use the command dotnet MyProject.dll to start your program.

在 .Net Core 3.0 中,他们添加了 exe,它实际上仍然只是上述命令的包装器.在其他操作系统上它也会创建一个可执行文件,它只是将其命名为 MyProject 而不是 MyProject.exe

With .Net Core 3.0, they added the exe, which is still really just a wrapper around the command above. On other operating systems it also creates an executable file, it just names it MyProject instead of MyProject.exe

如果人们有旧脚本仍然可以执行 dotnet 命令,此设置不会破坏它们,但如果您只想使用 exe,您也可以这样做.

If people have old scripts that still make the dotnet command, this setup doesn't break them, but if you want to just use an exe, you can do that too.

这篇关于为什么在编译 .NET Core 控制台应用程序时,我们最终会得到 dll 和 exe 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆