目次
サンプル定義ファイル
WiX の導入
使うツールは "candle.exe" と "light.exe" の2つで、コマンドラインからの起動になるため、"C:\Program Files (x86)\WiX Toolset v3.11\bin" にPATHを通しておく。
WixEdit
インストーラー作成用XMLファイル
拡張子は .wxs で保存する。
解説:変数定義
0002: <!-- WiXサンプル定義ファイル -->
0003: <!-- 参考サイト https://www.pahoo.org/e-soul/webtech/cpp01/cpp01-01-02.shtm -->
0004: <!-- 変数定義 -->
0005: <?define GUID_Product = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ?>
0006: <?define GUID_MenuAppComponent = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ?>
0007: <?define GUID_ApplicationComponent = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ?>
0008: <?define GUID_EtcComponent = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ?>
0009:
0010: <?define GUID_Upgrade = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ?>
0011: <?define GUID_MenuPahooComponent = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ?>
0012:
0013: <?define ProductName = "googlenewswin" ?>
0014: <?define ProductNameJP = "Googleニュース検索" ?>
0015: <?define ProductVersion = "1.1" ?>
0016: <?define MinumumVersion = "1.0" ?>
0017: <?define ProductComment = "インターネット経由でGoogleニュース検索を行い,検索結果を一覧表示・ファイル保存する.記事タイトルをクリックすると,ブラウザを使って当該ニュースを表示する." ?>
0018: <?define SourceFolder = "C:\SampleProgrram\cpp\googlenewswin\" ?>
<?define 変数名 ="変数の内容" ?>
GUID_Product | プロダクトのGUID |
GUID_MenuAppComponent | アプリケーションメニューのGUID |
GUID_ApplicationComponent | アプリケーションコンポーネントのGUID |
GUID_EtcComponent | etcコンポーネントのGUID |
GUID_Upgrade | アップグレードGUID |
GUID_MenuPahooComponent | pahooメニューコンポーネントのGUID |
ProductName | プロダクト名称(英数字) |
ProductNameJP | プロダクト名称(日本語) |
ProductVersion | プロダクト・バージョン(小数) |
MinumumVersion | アップデート可能なの最小(最古)バージョン |
ProductComment | プロダクトに関する説明。 |
インストールやアップデートは GUID_Upgrade を参照するので、同一プロダクトにつき、この GUID は同一にすること。
これから作るプログラムは、デフォルトでスタートメニューに pahoo.org フォルダを作成し、その配下にショートカットを配置していく。そこで、GUID_MenuPahooComponent の GUID も同一にすること。
これ以外のGUIDについては、アップデートの度にあらたに生成すること。
XML中で変数を参照するときは $(var.GUID_Product) のように記述する。
解説:Productエレメント
0020: <!-- WiX開始 -->
0021: <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
0022: <Product Id="$(var.GUID_Product)" Name="$(var.ProductNameJP)" Language="1041" Version="$(var.ProductVersion)" Manufacturer="www.pahoo.org" UpgradeCode="$(var.GUID_Upgrade)" Codepage="932">
Id | プロダクトコードGUID |
Name | プロダクトの説明的な名前 |
Language | 言語ID:日本語は1041 |
Version | バージョン番号 |
Manufacturer | プロダクトのメーカー |
UpgradeCode | プロダクトのためのアップグレードコードGUID(同一プロダクトでは常に同一) |
Codepage | MSIファイルのコードページ:日本語は932 |
解説:Packageエレメント
0024: <!-- パッケージ -->
0025: <Package Description="$(var.ProductNameJP)" Comments="$(var.ProductNameJP)" InstallerVersion="200" Compressed="yes" SummaryCodepage="932" Platform="x64" InstallScope="perMachine" />
0026: <Media Id="1" Cabinet="simple.cab" EmbedCab="yes" />
Description | プロダクトフルネームまたは説明。 |
Comments | ブラウズのためのオプションのコメント。 |
InstallerVersion | このパッケージをインストールするために必要な Windows Installer の最小のバージョン。200は Windows インストーラー 2.0 を表す。 |
Compressed | ソース中に圧縮ファイルを持つには 'yes' に設定。 |
SummaryCodepage | サマリーインフォメーション文字列だけのためのコードページ整数値またはウェブ名。 |
Platform | x64 はパッケージが x64 パッケージであることを表す。 |
InstallScope | perMachine はパッケージがマシンごとのインストールであり、インストールするために昇格された特権を必要とすると宣言する。 |
解説:Upgradeエレメント
0028: <!-- アップグレード -->
0029: <Upgrade Id='$(var.GUID_Upgrade)'>
0030: <UpgradeVersion OnlyDetect='yes' Property='SELFFOUND' Minimum='$(var.MinumumVersion)' IncludeMinimum='yes' Maximum='$(var.ProductVersion)' IncludeMaximum='yes' />
0031: </Upgrade>
解説:Directoryエレメント
0033: <Directory Id="TARGETDIR" Name="SourceDir">
0034: <Directory Id="DesktopFolder" SourceName="Desktop" />
0035:
0036: <!-- スタートメニュー -->
0037: <Directory Id="ProgramMenuFolder">
0038: <Directory Id="MenuPahoo" Name="pahoo.org">
0039: <Component Id="MenuPahooComponent" Guid="$(var.GUID_MenuPahooComponent)" Permanent="yes" Win64="yes">
0040: <CreateFolder Directory="MenuPahoo" />
0041: </Component>
0042:
0043: <Directory Id="MenuApplication" Name="$(var.ProductName)">
0044: <Component Id="MenuApplicationComponent" Guid="$(var.GUID_MenuAppComponent)" Win64="yes">
0045: <CreateFolder Directory="MenuApplication" />
0046: <RemoveFolder Id="MenuApplication" On="uninstall" />
0047: <RegistryValue Root="HKCU" Key="Software\pahoo.org\$(var.ProductName)\Menu" Name="Installed" Type="integer" Value="1" KeyPath="yes" />
0048: </Component>
0049: </Directory>
0050: </Directory>
0051: </Directory>
0052:
0053: <!-- プログラム配置 -->
ここでは、スタートメニューのディレクトリーレイアウトを定義している。
ProgramMenuFolder は、スタートメニューの実ディレクトリを指す定数である。
解説:プログラム配置
0053: <!-- プログラム配置 -->
0054: <Directory Id="ProgramFiles64Folder" Name="PFiles">
0055: <Directory Id="PAHOO_ORG" Name="pahoo.org">
0056: <Directory Id="ApplicationFolder" Name="$(var.ProductName)">
0057: <Component Id="ApplicationComponent" Guid="$(var.GUID_ApplicationComponent)" Win64="yes">
0058: <RemoveFolder Id="ApplicationFolderRemove" On="uninstall" />
0059: <File Id="APPLICATION_EXE" Name="$(var.ProductName).exe" Source="$(var.SourceFolder)Release\$(var.ProductName).exe" />
0060: <File Id="INSTALLER_MSI" Name="$(var.ProductName).msi" Source="$(var.SourceFolder)$(var.ProductName).msi" />
0061:
0062: <!-- DLL -->
0063: <File Id="LIBCRYPTO_1_1_X64.DLL" Name="libcrypto-1_1-x64.dll" Source="$(var.SourceFolder)Release\libcrypto-1_1-x64.dll" />
0064: <File Id="LIBSSL_1_1_X64.DLL" Name="libssl-1_1-x64.dll" Source="$(var.SourceFolder)Release\libssl-1_1-x64.dll" />
0065: <File Id="LIBCURL_X64.DLL" Name="libcurl-x64.dll" Source="$(var.SourceFolder)Release\libcurl-x64.dll" />
解説:Shortcutエレメント
0067: <!-- スタート・メニュー -->
0068: <Shortcut Id="startMenuShotcut" Name="$(var.ProductNameJP)" Description="$(var.ProductComment)" WorkingDirectory="ApplicationFolder" Icon="application.ico" Directory="MenuApplication" Target="[ApplicationFolder]$(var.ProductName).exe" />
0069:
0070: <!-- デスクトップ・ショートカット -->
0071: <Shortcut Id="DesktopShortcut" Name="$(var.ProductNameJP)" Description="$(var.ProductComment)" WorkingDirectory="ApplicationFolder" Icon="application.ico" Directory="DesktopFolder" Target="[ApplicationFolder]$(var.ProductName).exe" />
0072:
0073: <!-- アンインストーラ -->
0074: <Shortcut Id="UninstallProduct" Name="$(var.ProductNameJP)アンインストール" Description="$(var.ProductNameJP)をアンインストールする." Directory="MenuApplication" Target="[System64Folder]msiexec.exe" Arguments="/x {$(var.GUID_Product)} /qb" />
0075: <Shortcut Id="UninstallDesktopShortcut" Name="$(var.ProductNameJP)アンインストール" Description="$(var.ProductNameJP)をアンインストールする." Directory="DesktopFolder" Target="[System64Folder]msiexec.exe" Arguments="/x {$(var.GUID_Product)} /qb" />
0076:
0077: </Component>
Id | ショートカットの為のユニーク識別子 |
Name | ショートカット名 |
Description | 説明文 |
WorkingDirectory | ワーキングディレクトリ |
Icon | アイコンファイル |
Directory | ショートカットが作成されるディレクトリ |
Target | ターゲットファイル |
Arguments | コマンドライン引数 |
解説:ヘルプ・ファイル
0079: <!-- ヘルプ・ファイル -->
0080: <Directory Id="ETC" Name="etc">
0081: <Component Id="EtcFolder" Guid="$(var.GUID_EtcComponent)" Win64="yes" Feature="DefaultFeature">
0082: <File Id="HELP.CHM" Name="help.chm" Source="$(var.SourceFolder)Release\etc\help.chm" />
0083: </Component>
0084: </Directory>
Id | コンポーネント識別子 |
Guid | コンポーネントGUID |
Win64 | yesは64ビット・コンポーネントであることを示す |
Feature | このコンポーネントが属しているフィーチャーを識別する。 |
解説:Featureエレメント
0091: <Feature Id="DefaultFeature" Title="Main Feature" Level="1">
0092: <ComponentRef Id="ApplicationComponent" />
0093: </Feature>
解説:ユーザー・インターフェース
0095: <!-- ユーザー・インターフェース -->
0096: <Property Id="WIXUI_INSTALLDIR" Value="ApplicationFolder" />
0097: <UIRef Id="WixUI_InstallDir" />
0098: <!-- <UIRef Id="WixUI_Mondo" /> -->
0099: <WixVariable Id="WixUILicenseRtf" Value="$(var.SourceFolder)..\Wix\license.rtf" />
0100: <WixVariable Id="WixUIBannerBmp" Value="$(var.SourceFolder)..\Wix\banner.bmp" />
0101: <WixVariable Id="WixUIDialogBmp" Value="$(var.SourceFolder)..\Wix\dialog.bmp" />
0102:
0103: <Icon Id="application.ico" SourceFile="$(var.SourceFolder)application.ico" />
0104:
0105: </Product>
0106: </Wix>
参考サイト
- WiX(Windows Installer XML)
そこで、カスタマイズがやりやすいフリーソフト WiX(Windows Installer XML)を利用することにした。