152
130 shares, 152 points


All Windows purposes must be put in. Sure, you’ll be able to simply wrap your binaries and belongings in a zipper file and go away set up as an train in your customers, however meaning they’re unlikely to ever come again. That’s the place the varied Windows packaging and installer instruments are available, supplying you with a solution to construct executables that place all the varied components of your code in the appropriate place in a Windows set up, making certain that each one the mandatory dependencies are put in, and icons and shortcuts are within the begin menu, able to go.

How do you go about constructing an installer? Many of the instruments on the market reap the benefits of the usual Windows Installer packaging instruments, however getting that configuration proper could be onerous, particularly while you’re making packaging the ultimate a part of a CI/CD (steady integration and steady supply) construct course of. When your code, artifacts, and dependencies change from construct to construct, you want a scriptable configuration setting that may be managed by your construct instruments, built-in into your improvement setting and your code repository.

The first Microsoft open supply software was for builders

That’s the place WiX, the Windows Installer XML toolset, comes into play. It’s been used inside Microsoft for a very long time and made historical past as its first open supply launch in 2004 utilizing the Common Public License, ultimately being managed by the Outercurve Foundation earlier than being transferred to the .NET Foundation. Development has continued by way of that interval, with the mission leads founding FireGiant to supply business assist and extra instruments.

At its coronary heart, WiX is XML that’s used as declarative code that’s handled as supply for constructing installers. You can set up the WiX instruments in Visual Studio and write an installer alongside your software, utilizing the identical supply management and construct instruments to ship an installable bundle. It’s in a position to do greater than the essential Windows Installer, with assist for software and Windows configuration and the aptitude to work with server instruments equivalent to IIS and SQL Server. Additionally, it might create complicated setup bundles that deal with dependencies and conditions, making certain that your code has the whole lot it must run as soon as put in.

The present secure launch of WiX is Version 3.11.2, which has been accessible since 2019. That hole is because of the improvement workforce specializing in a brand new model with a brand new structure. A preview of WiX 4.0 is now accessible and is effectively value investigating. Built on trendy .NET, it’s extra appropriate to be used in a contemporary CI/CD setting. Everything is run from the .NET command line, permitting you to rapidly construct it into scripts and actions; it really works as a part of an Azure DevOps pipeline or in a GitHub Action. Push a brand new pull request to a department and get a ready-to-run installer.

Downloading and putting in WiX

You can obtain the present launch of the WiX toolset from GitHub, which is the place most improvement happens. There are repositories for the toolset, the Visual Studio extension, and core instruments that ship as a part of the platform. It’s a fairly energetic set of repositories, with many of the present instruments in upkeep mode whereas a lot of the work goes into the upcoming WiX 4.

WiX is a .NET software, written in C#. It presently makes use of the .NET Framework, with the under-development WiX 4 migrating to the brand new .NET platform, requiring a minimal of .NET Core v3.1. The new launch additionally brings the varied WiX instruments, like candle and lightweight, right into a single command-line utility. It now installs from the .NET command line as a .NET software.

Building an installer description in WiX

For now, you’re more likely to be utilizing WiX 3.x. It’s a great way to get accustomed to the underlying XML syntax used to construct installers. Although there’s some change between variations, utilizing the secure launch gives you an acceptable grounding and a set of installer information that may be upgraded when the brand new launch arrives.

WiX makes use of XML to outline the construction of an put in software, utilizing the definitions anticipated by the Windows Installer. You want to begin by defining the directories utilized by your software, working with the default Windows Program Files construction. You can create a hierarchy of directories for the information packaged together with your software right here, setting names in addition to indicating how directories are created on disk.

Once you’ve outlined your goal listing, you’ll be able to create an XML checklist of your software belongings. Each file wants its personal part reference, together with a GUID. GUIDs are essential, as WiX makes use of them to handle updates. Executable elements could be saved together with a checksum, which can validate information on set up.

Windows Installer is designed to work with a whole lot of information, so you’ll ultimately have to create an extended checklist of elements. In follow, you’ll must automate this, both utilizing the WiX extension in Visual Studio or having a part registry software that may generate the suitable XML for you. This could be so simple as an Excel spreadsheet with its built-in XML instruments.

Other XML components are used to outline and write registry keys, defining a root and a key, with acceptable values. Registry entries are handled as elements, so that they want a GUID together with their contents.

Working with the WiX Visual Studio extension

Using the Visual Studio extension can save a whole lot of time. You can create a brand new mission in your resolution for the installer XML. You can begin with one thing so simple as including a reference to an software and one line of code in your WiX mission. Once constructed, it can create your installer, prepared to be used. WiX’s Visual Studio software helps a number of completely different variables that may pre-populate installer XML. Alternatively, you should utilize it to construct your individual customized instruments.

One helpful characteristic of WiX is its decompiler that can be utilized with any Windows Installer bundle. This takes your installer and produces WiX code that may then be compiled and examined. It’s a very good software to have as it might deliver current installers constructed from different instruments into your WiX setting, prepared for use for updates and new releases.

Tools like WiX present that Microsoft and the open supply group can work collectively to construct instruments that everybody can use. Obviously, there are nonetheless inside WiX variations to cope with the size of Microsoft tasks like Windows, however the public instruments vastly simplify constructing and managing an installer. New command line–pushed instruments in WiX 4 (and a transfer to cross-platform and cross-processor .NET instruments) ought to make it so much simpler to automate working with installers, making them the default finish of a Windows software CI/CD pipeline.

Copyright © 2021 IDG Communications, Inc.


Like it? Share with your friends!

152
130 shares, 152 points

What's Your Reaction?

confused confused
0
confused
lol lol
0
lol
hate hate
0
hate
fail fail
0
fail
fun fun
0
fun
geeky geeky
0
geeky
love love
0
love
omg omg
0
omg
win win
0
win