在 C# 中部署控制台应用程序的方法

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

Ways to deploying console applications in C#

c#visual-studioconsole

提问by Dervin Thunk

I have a relatively complex console application which relies on several dlls. I would like to "ship" this in the best form. My preferred way would be an exe file with all dependencies embedded in it (not that big, about 800K). Another thing would be to just zip the contents of the "Debug" folder and make that available, but I'm not sure if everything will be available like that (will all dependencies be resolved just by zipping the debug folder?)

我有一个相对复杂的控制台应用程序,它依赖于几个 dll。我想以最好的形式“运送”它。我的首选方式是将所有依赖项嵌入其中的 exe 文件(不是那么大,大约 800K)。另一件事是压缩“Debug”文件夹的内容并使其可用,但我不确定是否所有内容都可用(是否所有依赖项都可以通过压缩调试文件夹来解决?)

What reliable practices exist for deploying console apps written in C# using VisualStudio 2008?

使用 VisualStudio 2008 部署用 C# 编写的控制台应用程序有哪些可靠的做法?

采纳答案by Jon Skeet

If you just copy the Foo.exe, dlls and Foo.exe.config files, it's likely to be okay. Have a look at what else is in the debug folder though - you (probably) don't want to ship the .pdb files, or Foo.vshost.exe. Is there anything else? If you've got any items marked as Content which are copied to the output folder, you'll need those too.

如果您只是复制 Foo.exe、dll 和 Foo.exe.config 文件,则可能没问题。看看调试文件夹中还有什么 - 您(可能)不想发送 .pdb 文件或 Foo.vshost.exe。还有别的事吗?如果您将任何标记为内容的项目复制到输出文件夹,您也需要这些项目。

You coulduse ilmergeto put all the dependencies into one exe file, but I'm somewhat leery of that approach - I'd stick with exe + dependency dlls.

可以使用ilmerge将所有依赖项放入一个 exe 文件中,但我对这种方法持怀疑态度 - 我会坚持使用 exe + 依赖项 dll。

回答by brien

You should look into setup projectsin Visual Studio. They let you set up dependencies and include the DLLs you need. The end result is a setup.exe and an MSI installer.

您应该查看Visual Studio 中的安装项目。它们允许您设置依赖项并包含您需要的 DLL。最终结果是 setup.exe 和 MSI 安装程序。

Here's a walkthroughthat should help.

这是一个应该有帮助的演练

回答by HasaniH

Create a setup project in VS08 and add the primary output of the console app project to it, this resolves the dependencies and packages them in a .msi

在 VS08 中创建一个安装项目并将控制台应用程序项目的主要输出添加到其中,这将解析依赖项并将它们打包在 .msi 中

回答by Cheeso

OR you could use a self-extracting ZIP file. Package all the normal files up - .exe, .dll, .config, and anything else - into a zip file. Extract into a temp directory and set the run-on-extract program to be the actual console exe.

或者您可以使用自解压 ZIP 文件。将所有普通文件 - .exe、.dll、.config 和其他任何文件 - 打包成一个 zip 文件。解压到一个临时目录并将运行时提取程序设置为实际的控制台 exe。

回答by alrightyy

You can use wix installers to bundle it. For console application, exe + dependicies DLLs + nuget DLLs , zipping them is enough.

您可以使用 wix 安装程序来捆绑它。对于控制台应用程序,exe + 依赖项 DLLs + nuget DLLs ,压缩它们就足够了。