Bartek Szafko

all of the bits and pieces

Archive for the ‘WiX’ Category

Instalator w pliku msi część 1

with one comment

Zapomniane instalki

Bardzo ważnym aspektem, każdej tworzonej aplikacji desktopowej jest instalacja. Ta część często bywa zaniedbywana przez twórców oprogramowania, a jej rola jest nie do przecenienia. Potencjalny klient szybko się zniechęca gdy nie może uruchomić, a co dopiero zainstalować aplikację. Tymczasem developerzy myślą raczej w kategoriach tworzenia aplikacji a zapewnienie prostej i powtarzalnej instalacji w ogóle nie jest umieszczane na liście funkcjonalności.

Narzędzia

Istnieje całkiem spora liczba narzędzi pozwalających zająć się tym problemem, spora część z nich jest komercyjna i raczej nadaje się do projektów ze sporymi budżetami. Pierwsze co przychodzi na myśl to Installshield – jest to naprawdę profesjonalne narzędzie mające wielu zwolenników, nie ma co się dziwić jest już na rynku sporo czasu.

Windows Installer XML

2 lata temu, gdy szukałem sensownej (również pod względem finansowym) metody zbudowania setupu dla małej aplikacji udało mi się znaleĽć WiX (Windows Installer Xml). Wtedy było naprawdę trudno go znaleĽć – zajęło mi to naprawdę sporo. Dla mojego projektu instalator tworzony przez visual studio 2005 w ogóle nie zdawał egzaminu. Po pierwsze instalacja była dostępna tylko po angielsku, a po drugie nie można było definiować bardziej zaawansowanych operacji ( można była wykorzystać custom action w .net, ale nie działały za dobrze).

Mało kto wie, że WiX jest pierwszym projektem open source wydanym prze Microsoft, dzięki sporemu zaangażowaniu Roba Menschinga. Narzędzie okazało się na tyle użyteczne, że również zespoły z wewnątrz MS zaczęły go używać.

WiX pozwala na podstawie stosunkowo prostych plików XML stworzyć pliki .msi, czyli popularne instalatory Windowsowe. WiX obsługuje praktycznie wszystko co można znaleĽć w specyfikacji MSI, uwzględnia wszystkie nowinki związane z Vistą i wersją 4.0 Windows Installera. To co dla mnie okazało się szczególnie fajne to integracja z Visual Studio za pomocą wtyczki Votive.

WiX – wersje

W tej chwili dostępne są 2 wersje Wixa 2.0 i 3.0. Pierwsza jest uważana za stabilną, ale osobiście polecam używanie 3.0, która zawiera najnowsze funkcjonalności. Co prawda czasem zdarzają się z nią małe problemy, ale z reguły upgrade załatwia sprawę.

Pliki .msi

Sam plik .msi jest bazą danych, w środku zawarte są są tabele, które z kolei mają kolumny i wiersze. Można nawet na nich wykonywać proste zapytania. Istnieje fajne narzędzie – Orca, które pozwala na podglądanie i edycję zawartości plików – w sam raz dla prawdziwych eksperymentatorów.

Linki:

  • Windows Installer Xml – strona główna projektu
  • WixWiki – niezłe Ľródło informacji
  • dzięki temu feedowi zawsze będziesz na bieżąco z Wix
  • a stąd możesz ściągnąć najaktualniejsze wersje
  • podcast – wywiad z Robem, w którym opowiada o początkach WiX
  • Orca – oficjalnie dostępna jako część windows sdk, ale w sieci można znaleĽć też “luĽnego” exeka

W następnym poście pokaże jak w prosty sposób zrobić instalatora w MSI.

Written by Bartłomiej Szafko

August 13th, 2008 at 9:47 pm

Posted in WiX

Lokalizowanie setupów WiX

without comments

Jeśli używasz WiX do tworzenia setupów z interfejsem mondo, tak jak to opisano w dokumentacji zapewne natknąłeś się na problem lokalizacji tekstów wyświetlanych w okienkach. Z moich doświadczeń wynika, że wystarczy wykonać parę prostych kroków, aby rozwiązać ten problem.

Read the rest of this entry »

Written by Bartłomiej Szafko

January 20th, 2008 at 12:00 pm

Posted in WiX

WiX: configureIIS custom action is executed despite no web related component is selected

without comments

Sometimes, when you have a complex setup which contains both web related components and other components.
Read the rest of this entry »

Written by Bartłomiej Szafko

January 15th, 2008 at 6:56 pm

Posted in WiX

Combining multiple WiX installers and retaining upgrade behaviour

without comments

Sometimes there is a need to combine multiple WiX installers into one. However one problem arises: the new – “combined” installer should upgrade ( remove ) old installers. In order to achieve that you have to use upgrade section in your WiX script.

First of all you have to create upgrade section for current installation then upgrade section for each product you have to upgrade. In the following example take a look on UpgradeCode in the first upgrade section and Id attribute in Product. The second upgrade section upgrades (removes) other product.
Read the rest of this entry »

Written by Bartłomiej Szafko

January 10th, 2008 at 8:08 pm

Posted in WiX

Setting connections strings in .config files with WiX

with 2 comments

This is usually a common feature request: to be able to modify a connection string in a .config file while installation with wix installer. The most simple thing to do is use a XmlFile( be careful as documentation is from 2.0 version) element.

Read the rest of this entry »

Written by Bartłomiej Szafko

January 1st, 2008 at 5:54 pm

Posted in WiX

Using managed custom actions with WIX 3

without comments

Embedding custom actions written in .net may be very tricky. Some setup developers even consider it evil. However I found that with some research and reverse engineering it could be quite simple.

First of all you need InstalUtilLib.dll it’s a library which contains ManagedInstall procedure. This procedure allows you to call an assembly consisting of Installer inherited class. In .net 2.0 it is found somewhere near %WINDIR%\Microsoft.NET\Framework\v2.0.50727 . You have to embed it in Binary table of MSI file.

You will also need MSVBDPCADLL. This library setups runtime environment for .net assembly. I’ve seen some installer using .net custom actions which run without this library, hovewer for me it turned out that this library is needed. The easiest way to obtain this library is either decompile a vs made setup using dark from wix, or orca tool from microsoft.

Finally an extensive config file is also needed. This file is quite big and it’s best to obtain it like MSVBDPCADLL. In vs genereated setup it is called VSDNETCFG.ibd and is also located in Binary table.

<Binary Id=InstallUtil SourceFile=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtilLib.dll />

<Binary Id=MSVBDPCADLL SourceFile=Binary\MSVBDPCADLL.ibd />

<Binary Id=VSDNETCFG SourceFile=Binary\VSDNETCFG.ibd />

Now you can embed custom action like a normal file inside component

<File Id="MyCustomActionDll"  Name="MyCustomAction.dll" Source="MyCustomAction.dll" />

Now it is time to create custom actions. First of all you have to create an action to call CheckFX from MSVBDCALL. It does some magic, which is unclear for me at the moment and sets VSDFxConfigFile property which will be used as a config file. You also need a custom action to call your assembly. You will need one customaction to set a property with commandline to call and another one which calls ManagedInstall from installutil. The property has to be named exactly the same as custom action calling ManagedInstall.

<CustomAction Id=SetPrereqs BinaryKey=MSVBDPCADLL DllEntry=CheckFX />

<CustomAction Id=MyCASetProp Property=MyCA Value=/installtype=notransaction /action=install /LogFile= &quot;[#MyCustomActionDll]&quot; &quot;[VSDFxConfigFile]&quot;/>

<CustomAction Id=MyCA BinaryKey=InstallUtil DllEntry=ManagedInstall Execute=deferred />

Finally you have to instruct msi to execute your actions

<InstallExecuteSequence>

  <Custom Action=SetPrereqs After=InstallFiles>NOT Installed</Custom>

  <Custom Action=MyCASetProp After=SetPrereqs>NOT Installed</Custom>

  <Custom Action=MyCA After=MyCASetProp>NOT Installed</Custom>

</InstallExecuteSequence>

kick it on DotNetKicks.com

Written by Bartłomiej Szafko

November 6th, 2006 at 8:13 pm

Posted in .NET,General,WiX