简体   繁体   English

如何使用 Visual Studio Code 创建新的可执行 C# 项目

[英]How to create a new executable C# project with Visual Studio Code

I want to create a new executable project with Visual Studio Code + omnisharp.我想用 Visual Studio Code + omnisharp 创建一个新的可执行项目。 It works for dll but not for an exe file.它适用于 dll 但不适用于 exe 文件。

  1. Created a folder for my new project (eg myApp)为我的新项目创建了一个文件夹(例如 myApp)
  2. Open Visual studio code -> file -> open folder打开 Visual Studio 代码 -> 文件 -> 打开文件夹
  3. Open internal VSC terminal and type the following commands打开内部 VSC 终端并键入以下命令

Code:代码:

dotnet new console (pressed yes in popup)
dotnet restore
dotnet run
//hello world was visible in terminal (what means it works)
dotnet build

Build was successful but a dll file was created.构建成功,但创建了 dll 文件。

  • Actual result: dll file实际结果:dll 文件
  • Expected result: exe file预期结果:exe文件

BTW: I used this for help -> https://github.com/dotnet/docs/blob/master/docs/core/tutorials/with-visual-studio-code.md顺便说一句:我用它来寻求帮助-> https://github.com/dotnet/docs/blob/master/docs/core/tutorials/with-visual-studio-code.md

You are using dotnet core, so executable files are still in .dll. 您使用的是dotnet core,因此可执行文件仍位于.dll中。 To run the file, run dotnet nameofdll.dll 要运行该文件,请运行dotnet nameofdll.dll

dotnet core is cross-platform, and to reduce the tight coupling with windows, .exe is not used for executables anymore. dotnet core是跨平台的,为了减少与Windows的紧密耦合, .exe不再用于可执行文件。

If you want your application to be Windows dependant, you will need to make your application target .Net Framework instead - you will get a .exe instead this way. 如果希望您的应用程序依赖Windows,则需要将应用程序的目标设置为.Net Framework,而您将通过这种方式获得一个.exe。

ok heres how i did it好的,我是怎么做到的

if you go into the folder where the app is and go to bin/debug/net6.0如果您将 go 放入应用程序所在的文件夹,并将 go 放入 bin/debug/net6.0

i found a exe file along with four other files i have no idea what they do我发现了一个 exe 文件以及其他四个文件,我不知道它们在做什么

and a file called publish, also try F1 and searching for publish that might make these files appear (publish seems to be the same 5 files outside of the publish file)和一个名为发布的文件,也尝试 F1 并搜索可能使这些文件出现的发布(发布似乎是发布文件之外的相同 5 个文件)

and to the people who downvoted my terrible joke to literal extinction以及那些将我的可怕笑话贬为真正灭绝的人

there, ya happy?在那里,你快乐吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何添加 C# 扩展以在 Visual Studio 中创建新项目 - How to add C# extension to create a new project in visual studio 如何在Visual Studio Code中以.csproj扩展名创建C#项目? - How to create C# project with .csproj extension in Visual Studio Code? 如何使用 Visual Studio Code 创建 C# 项目? - How to create a C# project using Visual Studio Code? 如何从 Visual Studio 项目创建可执行文件 - How To Create An Executable from Visual Studio Project 我需要在 Visual Studio Code 中创建一个新的 c# 文件 - I need to create a new c# file in Visual Studio Code 如何在Visual Studio C中创建“项目概述”# - How do I create a “Project overview” in Visual Studio C# 如何在 Visual Studio 2022 中正确创建 C# WinUI 项目? - How to properly create a C# WinUI project in Visual Studio 2022? Visual Studio 2008 / C#:如何在项目中找到死代码? - Visual Studio 2008 / C# : How to find dead code in a project? 如何确定C#Visual Studio项目生成的可执行文件和DLL? - How do you determine what executable and DLL’s a C# Visual Studio project produces? 如何在Visual Studio 2010中的C#项目的已编译可执行文件中打包dll - How to package dlls in the compiled executable of a C# project in Visual Studio 2010
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM