21

Hoping this is still on-topic for StackOverflow.

I'm doing all my development on a Linux machine, but the code will be run by both Linux and Windows machines.

I'd like to use Linux to compile the code, and I have mingw-32 and mingw-w64 for that.

But I'd like to package the resulting executables into a nice MSI installation file. Is it possible to do this using utilities in Linux or running under Wine?

Thanks!

Richard
  • 56,349
  • 34
  • 180
  • 251
  • @IgnacioVazquez-Abrams, I don't dislike it... in fact, I'd never heard of it. Feel free to suggest it as a possible answer. – Richard Apr 20 '12 at 05:13
  • 18
    I dislike NSIS because it doesn't bring any of the advanced capabilities of Windows Installer. It's an arcane, legacy, imperative scripting language compared to a declarative, transactional, core windows service that provides consistent support for upgrading, patching, resilency, uninstall, logging, command line usage and so on. The difference is night and day. – Christopher Painter Nov 08 '12 at 14:32
  • NSIS is incapable of creating MSI installers as outlined here: http://stackoverflow.com/a/1863053/3196753. That said, you can `apt-get` it, you can `brew install` it and you can run it on Windows, making it a very nice scriptable, C.I.-able, cross-platform solution, if you're ok with the "arcane, legacy, imperative scripting language." that comes along with it. :) Here's an example application that uses NSIS with cmake. https://github.com/LMMS/lmms/blob/master/cmake/nsis/CMakeLists.txt – tresf Apr 28 '16 at 21:18
  • @IgnacioVazquez-Abrams: This is the first time I've visited here since getting additional privileges. I see that you did provide an NSIS-based answer and that it was pretty soundly rejected. I'm sorry that happened: I feel it was a valid response, especially given our discussion in the comments. I wish Arafangion had read the foregoing comments and respected my stance. – Richard Apr 29 '16 at 07:00
  • Thanks, @QZSupport. Despite ChristopherPainter's highly-ranked comment, I'd happily upvote an answer which outlined how to use NSIS as well as its pros/cons. – Richard Apr 29 '16 at 07:03
  • 1
    S'all good. I'm about 350k rep past getting salty about it ;) – Ignacio Vazquez-Abrams Apr 29 '16 at 07:03
  • @Richard, many open source products use mingw to cross-compile and then chain NSIS into the build process. This topic touches base on it (assuming your build system is `cmake`), but it's a bit dated. mingw can run on Windows or *nix, so the accepted answer talking about needing Visual Studio isn't necessarily true. http://stackoverflow.com/questions/13144181/how-to-create-an-installer-with-cmake-cpack-nsis-on-windows. A proper answer to this would have a C++ hello world, built with mingw, packaged with NSIS and produce an installer. This 1. Wouldn't be an MSI and 2. Wouldn't use Wine. :\ – tresf Apr 30 '16 at 15:58
  • Hit the comment limit... :) also, if for some reason you're not coding in C++, but rather another language, that information would be helpful as well. Java uses ant/maven for building and the NSIS integration effort would be much different versus `cmake`, but it would still be off-topic to the question unless it were rewritten. – tresf Apr 30 '16 at 16:01
  • @QZSupport: Thanks. I'm using C++. – Richard Apr 30 '16 at 18:15
  • 1
    @QZSupport true, NSIS can build installers too, but the MSI framework is more robust, especially in dealing with uninstall of previous versions and with return codes in case of failure – madduci Aug 28 '17 at 10:52

2 Answers2

16

You can use a combination of Wine, Mono and WiX to create .msi packages on Linux.

For openSUSE, I have created a wrapper package called wixwine which gives you the 'candle' and 'light' commands from the Windows Installer XML (WiX) toolset ready to use on Linux.

You can find my wixwine package here

yprez
  • 14,854
  • 11
  • 55
  • 70
Hib Eris
  • 161
  • 1
  • 3
  • 1
    For the record, I haven't managed to get any version later than wix 3.5 working under wine, apparently because they require not well supported .net versions. But 3.5 works just fine. – Vincent Fourmond Jan 11 '16 at 12:43
8

I just released v0.01 of msitools, a collection of utilities to inspect and create Windows Installer files. It is based on the Wine code, but ported to POSIX.

You can find the source and binary packages at http://bonzini.fedorapeople.org/ - unfortunately you will need to build libgsf from git, because I found a bug and no released version has the fix as of now. The linked page has Fedora RPMs with the fix.

$ msiinfo streams ~/download/Firefox-16.0.2-it.msi 
Binary.New
Binary.Up
Binary.info
Binary.dlgbmp
Binary.CustomBin
Binary.bannrbmp
Binary.completi
Binary.custicon
Binary.exclamic
Binary.insticon
Binary.removico
Binary.repairic
_MAKEMSI_Cabs.MM01.cab
Binary.BannerGraphic.BMP
Icon.firefox.16.0.2.0.ico.exe
DigitalSignature
SummaryInformation
$ msiinfo extract ~/download/Firefox-16.0.2-it.msi _MAKEMSI_Cabs.MM01.cab > firefox.cab
$ cabextract -l firefox.cab
Viewing cabinet: firefox.cab
 File size | Date       Time     | Name
-----------+---------------------+-------------
    917984 | 24.10.2012 12:50:38 | firefox.exe
     18912 | 24.10.2012 12:50:38 | AccessibleMarshal.dll

There is a companion utility msibuild to build MSIs. It is very low-level, but you can use the two tools together to make small changes to an MSI you already made on Windows.

update: now hosted at https://live.gnome.org/msitools, it also has a tool (wixl) that supports a subset of the WiX XML. Requires libgsf 1.14.25 or newer. Fedora 18 and newer have it packaged.

Paolo Bonzini
  • 1,900
  • 15
  • 25