编码安装程序

发布于 2024-10-22 05:04:11 字数 91 浏览 0 评论 0原文

是否可以编写自己的 C# 应用程序来创建安装程序(我的意思是编写安装程序,而不使用 InstallShield 或 Visual Studio 安装项目或其他任何东西?

Is it ok to code your own c# application in order to create your installer (I mean code the installer, an not use InstallShield or Visual Studio setup project or anything else?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

血之狂魔 2024-10-29 05:04:11

是的,这样做是“可以”的,但我质疑这种愿望 -

这样做的问题有两个:

  1. 您正在做安装程序可以为您做的很多工作,并且可能做得更好,因为它们已经过严格的测试。为什么要避免使用可以完成合理工作的完美工具来开发自己的(可能很差)替代品?

  2. 如果您使用 C# 进行编码,则需要先安装 .NET 框架,然后才能执行安装程序。通常,本机引导程序会在调用安装程序之前确保框架已安装。

Yes, it's "okay" to do that, but I question the desire -

The problem with doing this is two fold:

  1. You're doing a lot of work that an installation program can do for you, and probably do better, as they've been tested heavily. Why avoid a perfectly good tool that does a reasonable job in order to develop your own (likely poor) substitute?

  2. If you code this in C#, you'll have a requirement that the .NET framework be installed prior to your installer being able to execute. Normally, a native bootstrapper makes sure the framework is installed before calling your installer.

鹤舞 2024-10-29 05:04:11

如果“确定”意味着“推荐”,那么“不”,则应该使用 ClickOnce 相反,它比编写自己的解决方案更容易/更快。

If by ok you mean recommended then no, you should use ClickOnce instead, it is a lot easier/faster than coding you own solution.

对你的占有欲 2024-10-29 05:04:11

从某种意义上说,您将重新发明轮子,并且根据安装的复杂性,您很可能会出错。安装人员知道如何正确调用安装 API 来注册要卸载的应用程序。他们知道如何正确安装 Windows 服务、创建开始菜单项、设置快捷方式等,...

我个人衷心推荐 WiX。它为您提供基于 MSI 安装的所有灵活性以及基于 xml 脚本的灵活性和简便性。

编写批处理脚本来将应用程序复制到位并创建一些注册表项非常容易。如果安装的任何部分失败,确保安装程序回滚事务并非易事。这是 MSI 安装所固有的,并且是交付应用程序的首选方式。

如果您不想学习 WiX,也不关心使用 MSI(基于数据库的事务性)安装,至少看一下 NSIS。只需几行脚本即可轻松完成基本安装程序,并且它至少会正确调用安装 API。另外,您还可以获得一个漂亮的 GUI。请参阅http://nsis.sourceforge.net

In a sense, you're going to be reinventing the wheel, and the odds are good that, depending on the complexity of your install, you're going to get it wrong. Installers know how to call into the setup api correctly to register the application for uninstall. They know how to correctly install a windows service, create start menu items, set up shortcuts, etc, ....

I heartily recommend WiX, personally. It gives you all of the flexibility of an MSI-based install, with the flexibility and easy of an xml-based script.

It's very easy to write a batch script to xcopy an app into place and create some registry entries. It's not trivial to make sure that the installer rolls back the transaction if any part of the install fails. This is inherent to an MSI install, and is the preferred way to deliver an application.

If you don't want to learn WiX, and don't care about using an MSI (database-based, transactional) install, at least take a look at NSIS. It's incredibly easy to do a basic installer in only a couple lines of script, and it'll at least call the setup APIs correctly. Plus, you get a nice GUI. See http://nsis.sourceforge.net

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文