简体   繁体   English

您如何在安装程序中“包装”您的应用程序?

[英]How do you “wrap” your application in an installer?

To start with this is maybe a vague question and it might not have a well-structured answer, so it may not comply with SO rules. 首先,这可能是一个模糊的问题,并且可能没有一个结构合理的答案,因此它可能不符合SO规则。

So far I have written several rather small applications but all of them consisted of an executable file that would run "as is". 到目前为止,我已经编写了几个相当小的应用程序,但是它们全部由一个可“按原样”运行的可执行文件组成。 This means that the actual application didn't require any installation to use beforehand, you could simply download the file online, run it and you are set to go. 这意味着实际的应用程序不需要任何安装即可使用,您可以简单地在线下载文件,运行它,然后就可以使用了。

Most of the applications online require you to download an installer . 在线上的大多数应用程序都要求您下载安装程序 Then you set some preferences (namely where you want to place the files of the application, who is the main user etc) and when you are done the installation starts unzipping(?) the files required to actually run the application. 然后设置一些首选项(即要放置应用程序文件的位置,主要用户是谁等),完成后,安装开始解压缩(?)实际运行该应用程序所需的文件。

I suppose that the installer is a wrapper that includes your code and/or any other resources you may be utilizing. 我想安装程序是一个包装程序,其中包含您的代码和/或您可能正在使用的任何其他资源。 Can anyone guide me to some relevant info about this process? 谁能指导我有关此过程的一些相关信息? I do not have a relative problem, maybe it's not clear what I am asking, I am just curious as how things work. 我没有相对的问题,也许不清楚我要问的是什么,我只是对事情的运作方式感到好奇。

The standard Windows Installer experience is accomplished by creating a setup package known as an MSI file. 通过创建称为MSI文件的安装程序包,可以实现标准的Windows Installer体验。 An MSI, upon being launched by the user, installs components (files, registry keys, runtime components, other setup package, etc...). 由用户启动的MSI将安装组件(文件,注册表项,运行时组件,其他安装程序包等)。 The MSI install experience can be configured to have a UI. 可以将MSI安装体验配置为具有UI。 The usual approach being the stock "wizard" UI that the user can click "next" through as he chooses the setup options (eg install location). 通常的方法是股票“向导” UI,用户可以在选择设置选项(例如安装位置)时单击“下一步”。 The nice thing about MSIs is that they automatically come with an "uninstaller" that shows up in Control Panel's Add/Remove Programs dialog. MSI的好处在于,它们自动带有一个“卸载程序”,该卸载程序显示在“控制面板”的“添加/删除程序”对话框中。 If the user cancels the setup (or something fails to install), it performs automatic rollback. 如果用户取消设置(或安装失败),它将执行自动回滚。

Visual Studio usually includes a set of project types called "Setup package" which gives you support for creating rudimentary installer wrappers. Visual Studio通常包括一组称为“安装程序包”的项目类型,它为您提供了创建基本安装程序包装程序的支持。 This will likely meet your needs if all you are installing are a handful of files. 如果仅安装少量文件,这将可能满足您的需求。

I recommend using the WIX Toolset , which is an open source project sponsored by Microsoft, to build setup packages. 我建议使用WIX Toolset (它是Microsoft赞助的一个开源项目)来构建安装程序包。 WIX gives you a lot more control over the entire setup process. WIX为您提供了对整个设置过程的更多控制。 There's some learning overhead with it, but you'll find this to be the most flexible. 它有一些学习开销,但是您会发现这是最灵活的。

One other quick point. 另一个快速点。 Rarely do Windows EXEs run "as is". Windows EXE很少按“原样”运行。 Whether it be a .NET EXE or an app built with C/C++, there's usually a dependency on a runtime such as a particular version of .NET or the Visual Studio CRT. 无论是.NET EXE还是使用C / C ++构建的应用程序,通常都依赖于运行时,例如特定版本的.NET或Visual Studio CRT。 Typically, when you develop such EXEs, they do indeed run as is on your own computer. 通常,当您开发此类EXE时,它们确实确实可以在您自己的计算机上运行。 That because Visual Studio installed all those dependencies for you. 那是因为Visual Studio为您安装了所有这些依赖项。 Copy that same executable to another computer running an older version of Windows and you might find it doesn't run. 将同一可执行文件复制到另一台运行旧版Windows的计算机上,您可能会发现它没有运行。 You'll want to come up to speed on understanding how to embed .NET versioning and embedding the CRT with respect to your setup package. 您将需要加快了解如何嵌入.NET版本和相对于安装程序包嵌入CRT的速度。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM