如何创建 MSI 设置?

多年来,我用 Inno Setup 为我所有的 Delphi 工具创建了设置。现在有些用户更想要一个 MSI 安装包,这样他们就可以将设置从一个中央服务器部署到所有工作站。

我如何创建一个? 我必须购买 Visual Studio 或其他产品吗?

190727 次浏览

Look for Windows Installer XML (WiX)

You can use Visual Studio - that's paid.

You can use https://www.advancedinstaller.com/ - that has a free edition.

You can use http://nsis.sourceforge.net/Main_Page - for example Winamp uses this installer - and is very configurable and is Open Source.

You can use Wix (which is free) to create an MSI installation package.

WiX Tutorial - Creating an Installer MSI with Wix

Google "Freeware MSI installer".

e.g. https://www.advancedinstaller.com/

Several options here:

http://rbytes.net/software/development_c/install-and-setup_s/

Though being Windows, most are "shareware" rather than truly free and open source.

You can purchase InstallShield, the market leader for creating installation packages. It offers many features beyond what you get with freeware solutions.

Warning: InstallShield is insanely expensive!

If you don't understand Windows Installer then I highly recommend The Definitive Guide to Windows Installer. You can't really use WiX without understanding MSI. Also worth downloading is the Windows Installer 4.5 SDK.

If you don't want to learn the Windows Installer fundamentals, then you'll need some wizard type package to hide all the nitty gritty details and hold your hand. There are plenty of options, some more expensive than others.

  • InstallShield
  • Advanced Installer
  • MSI Factory
  • etc..

However still I'd suggest picking up the above book and taking some time to understand what's going on "under the hood", it'll really help you figure out what's going wrong when customers start complaining that something is broken with the setup :)

You can use "Visual studio installer project" and its free...

This is very easy to create installer and has GUI.(Most of the freeware MSI creation tool does not have a GUI part)

You will find many tutorials to create an installer easily on the internet

To install. just search Visual Studio Installer Project in your Visual Studio

Visual Studio-> Tools-> Extensions&updates ->search Visual Studio Installer Project. Download it and enjoy...

In my opinion you should use Wix#, which nicely hides most of the complexity of building an MSI installation pacakge.

It allows you to perform all possible kinds of customization using a more easier language compared to WiX.

In Visual Studio (including the free community editions) you can install the Microsoft Visual Studio Installer Projects extension [1] which allows you to create an MSI installation package. To install it from within Visual Studio:

  1. Go to Extensions -> Manage Extensions in the menu bar
  2. Search for Installer Projects in the search box
  3. Select Microsoft Visual Studio Installer Projects and hit Download
  4. Restart Visual Studio

Once the extension is installed, you'll create a new project that will contain all of the files and settings for the MSI. To do this:

  1. Go to File -> New -> Project in the menu bar
  2. Change the drop down menus visible to show All languages, All platforms, and All project types respectively
  3. Scroll down in the project type list and towards the bottom select Setup Wizard: Create a Windows Installer project with the aid of a wizard.
  4. Hit Next.

Work through the prompts to choose the installer project name and location. Choose Create a setup for a Windows application at Step 2 and in Step 3 choose the executable and other files that should be included in the MSI (hit Add..). At the end, hit Create.

To build the actual MSI go to Build -> Build Solution in the top menu, and you should see a message like the following in the Output window:

Build started...
------ Starting pre-build validation for project 'Setup1' ------
------ Pre-build validation for project 'Setup1' completed ------
------ Build started: Project: Setup1, Configuration: Debug ------
Building file 'C:\Users\zelda\Source\Repos\Setup1\Setup1\Debug\Setup1.msi'...
Packaging file 'test.exe'...
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========

What's created by default is a very basic MSI, but for additional configuration like creating custom actions, adding/changing registry keys, configuring the user interface associated with the MSI, etc., see the full documentation [2]

[1] https://marketplace.visualstudio.com/items?itemName=VisualStudioClient.MicrosoftVisualStudio2017InstallerProjects

[2] https://aka.ms/vdproj-docs