C# 如何在 Visual Studio 2008 中创建单个可执行文件?

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

How to create a single executable file in Visual Studio 2008?

c#visual-studio-2008.net-3.5executable

提问by

I've created a Windows Forms Application in Visual Studio 2008, .NET 3.5. Now I want to finalize my project, i.e. to create a single .exe file which I can give to someone and he will be able to run it on his computer.

我在 Visual Studio 2008、.NET 3.5 中创建了一个 Windows 窗体应用程序。现在我想完成我的项目,即创建一个单独的 .exe 文件,我可以将它提供给某人,他将能够在他的计算机上运行它。

In my project files I found bin/Debug directory where I see a .exe file. Can I just use this file as is, or I am missing some important finalizing procedure ?

在我的项目文件中,我找到了 bin/Debug 目录,在那里我看到了一个 .exe 文件。我可以直接使用这个文件吗,或者我错过了一些重要的定稿程序?

Thanks !

谢谢 !

采纳答案by Richard Szalay

You can just take the EXE as long as it has no dependencies. If there are any dll files in there, you need to include them (or use the ILMerge command line utilityto combine them). You can, however, ignore any generated pdb or xml files.

只要没有依赖项,您就可以使用 EXE。如果那里有任何 dll 文件,您需要包含它们(或使用ILMerge 命令行实用程序将它们组合起来)。但是,您可以忽略任何生成的 pdb 或 xml 文件。

As a side note, you should be compiling in release if you plan on deploying your project (the output will be in bin/Release)

作为旁注,如果您计划部署您的项目,您应该在发布中进行编译(输出将在bin/Release

回答by claws

You are not clear in you question. If your solutions output is just a single exe file, then Yes, you can give away the exe file in bin\debug.

你的问题不清楚。如果您的解决方案输出只是一个单独的 exe 文件,那么是的,您可以在 bin\debug 中放弃该 exe 文件。

But instead of bin\debug\ exe you must distribute the bin\Release\ exe which is meant for release purpose.

但是你必须分发 bin\Release\ exe 而不是 bin\debug\ exe,这是为了发布目的。

回答by SetiSeeker

To make the ILMerge easier, use the GUI tool from codeplex at http://ilmergegui.codeplex.com/

为了使 ILMerge 更容易,请使用http://ilmergegui.codeplex.com/ 上的codeplex 的 GUI 工具

If this is a commercial application, several commercial obfuscators allow creating a single exe.

如果这是一个商业应用程序,几个商业混淆器允许创建单个 exe。