如何编译完成的 C# 项目,然后在 Visual Studio 之外运行?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1057878/
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-06 07:11:13  来源:igfitidea点击:

How to compile the finished C# project and then run outside Visual Studio?

c#projects

提问by tintincutes

I just finished designing a simple code program. I called it a "Guessing Game". The program is so far working fine and I would like to open it without opening my Microsoft Visual Studio.

我刚刚设计了一个简单的代码程序。我称之为“猜谜游戏”。到目前为止,该程序运行良好,我想在不打开 Microsoft Visual Studio 的情况下打开它。

How can I do that?

我怎样才能做到这一点?

采纳答案by Matthew Scharley

The easiest way is:

最简单的方法是:

  • Find the drop-down box at the top of Visual Studio's window that says Debug
  • Select Release
  • Hit F6to build it
  • Switch back to Debugand then close Visual Studio
  • Open Windows Explorer and navigate to your project's folder (My Documents\Visual Studio 200x\Projects\my_project\)
  • Now go to bin\Release\and copy the executable from there to wherever you want to store it
  • Make shortcuts as appropriate and enjoy your new game! :)
  • 找到 Visual Studio 窗口顶部的下拉框,上面写着Debug
  • 选择发布
  • 点击F6构建它
  • 切换回调试,然后关闭 Visual Studio
  • 打开 Windows 资源管理器并导航到您的项目文件夹 ( My Documents\Visual Studio 200x\Projects\my_project\)
  • 现在转到bin\Release\并将可执行文件从那里复制到您想要存储它的任何位置
  • 根据需要制作快捷方式并享受您的新游戏!:)

回答by Adrian Godong

On your project folder, open up the bin\Debug subfolder and you'll see the compiled result.

在您的项目文件夹中,打开 bin\Debug 子文件夹,您将看到编译结果。

回答by TcKs

In the project file is folder "bin/debug/your_appliacion_name.exe". This is final executable program file.

在项目文件中是文件夹“bin/debug/your_appliacion_name.exe”。这是最终的可执行程序文件。

回答by sharptooth

Compile the Release version as .exe file, then just copy onto a machine with a suitable version of .NET Framework installed and run it there. The .exe file is located in the bin\Release subfolder of the project folder.

将 Release 版本编译为 .exe 文件,然后只需将其复制到安装了合适版本的 .NET Framework 的机器上并在那里运行。.exe 文件位于项目文件夹的 bin\Release 子文件夹中。

回答by Eduardo Arruda

If you cannot find the .exe file, rebuild your solution and in your "Output" from Visual Studio the path to the file will be shown.

如果找不到 .exe 文件,请重建您的解决方案,并在 Visual Studio 的“输出”中显示该文件的路径。

Build solution path.

构建解决方案路径。

回答by Davejade

I'm using Visual Studio 2017.

我正在使用 Visual Studio 2017。

  1. Go to dropdown box build.
  2. Choose Pubish Guessing Game (or whatever your project is called.
  3. Wiz Box opens so tell it where to publish it and click Next.
  4. Choose how to install (I usually choose CD-ROM). click Next.
  5. Choose updates check (I usually choose no check) click Next.
  6. Click Finish
  1. 转到下拉框构建。
  2. 选择发布猜谜游戏(或任何您的项目名称。
  3. Wiz Box 打开,告诉它在哪里发布它,然后单击下一步。
  4. 选择安装方式(我一般选择CD-ROM)。点击下一步。
  5. 选择更新检查(我通常选择不检查)单击下一步。
  6. 单击完成

It will publish, complete with setup file to the location you specified.

它将连同安装文件一起发布到您指定的位置。

Hope this helps

希望这可以帮助