Windows Installer パッケージを作成する事についての基礎を 楽に操る事ができるので、 次のレベルに進んで CustomAction を追加しましょう。この例は、"FooAction" と呼ばれる binary CustomAction を どのように作り出すかを 見せています。世間の人々が用いる 共通のサンプルは、インストールの一部として notepad.exe やその他のアプリケーションを 起動する DLL CustomAction です。始める前に、"FooEntryPoint" と呼ばれるエントリー ポイントを持つ サンプル DLL が必要です。
プロダクト定義として CustomAction 定義を 同じソースファイル内に置くよりもむしろ、 少しモジュール方式を 練習して、"ca.wxs" と呼ばれる CustomAction を定義する為に 新しいソースファイルを作りましょう。
<?xml version='1.0'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
<Fragment>
<CustomAction Id='FooAction' BinaryKey='FooBinary' DllEntry='FooEntryPoint' Execute='immediate'
Return='check'/>
<Binary Id='FooBinary' SourceFile='foo.dll'/>
</Fragment>
</Wix>
OK、思った通り。"ca.wxs" ソースファイルを編集する事で 終わった。そのわずかのコードは コンパイルしなければならないけれど、リンクはしない。リンクするのは、エントリーセクションが 必要だという事を 忘れないで。<Fragment/> 単独では、エントリーセクションじゃありません。 うまく完了するには このソースファイルを <Product/> か <Module/> を含む ソースファイルと一緒にリンクする必要があります。
<?xml version='1.0'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
<Product Id='PUT-GUID-HERE' Name='Test Package' Language='1033'
Version='1.0.0.0' Manufacturer='Microsoft Corporation'>
<Package Description='My first Windows Installer package'
Comments='This is my first attempt at creating a Windows Installer database'
Manufacturer='Microsoft Corporation' InstallerVersion='200' Compressed='yes' />
<Media Id='1' Cabinet='product.cab' EmbedCab='yes' />
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='ProgramFilesFolder' Name='PFiles'>
<Directory Id='MyDir' Name='Test Program'>
<Component Id='MyComponent' Guid='PUT-GUID-HERE'>
<File Id='readme' Name='readme.txt' DiskId='1' Source='readme.txt' />
</Component>
<Merge Id='MyModule' Language='1033' SourceFile='module.msm' DiskId='1' />
</Directory>
</Directory>
</Directory>
<Feature Id='MyFeature' Title='My 1st Feature' Level='1'>
<ComponentRef Id='MyComponent' />
<MergeRef Id='MyModule' />
</Feature>
<InstallExecuteSequence>
<Custom Action='FooAction' After='InstallFiles'/>
</InstallExecuteSequence>
</Product>
</Wix>
それら3行が、"FooAction" CustomAction を呼ぶのに Windows Installer パッケージ ソースファイルに追加する必要のある すべてです。一緒にリンクするファイルが2つあるので、 light.exe へのコールは少し より複雑になります。コンパイル、リンク、インストール ステップは こうです。
C:\test> candle product.wxs ca.wxs C:\test> light product.wixobj ca.wixobj -out product.msi C:\test> msiexec /i product.msi
インストールの一部として今、"FooAction" が行うことになっている事は何であれ、 InstallFiles action のあとに発生するのを見るはずです。