Last active
May 29, 2017 04:35
-
-
Save gocha/0fcd628b527d2034164fa23ebdc90300 to your computer and use it in GitHub Desktop.
WiX: 単純な wxs ファイルによるインストーラーのサンプル
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!-- | |
Visual Studio で WiX プロジェクトを扱う際は、 | |
構成プロパティの Build にある Cultures to build に ja-JP を指定する。 | |
--> | |
<?if $(var.Platform) = x64 ?> | |
<?define Win64 = "yes" ?> | |
<?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?> | |
<?else ?> | |
<?define Win64 = "no" ?> | |
<?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?> | |
<?endif?> | |
<!-- 注意事項: | |
* GUID は必ず一意にする。コードをコピーする場合、GUID を流用しないように注意する。 | |
* 新しいバージョンをリリースする際は、適切な Product Version を設定する。 | |
--> | |
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> | |
<Product Id="*" | |
Name="製品名" | |
Version="2.2.0.0" | |
Manufacturer="製造元" | |
Language="1041" | |
Codepage="932" | |
UpgradeCode="YOURGUID-ffff-ffff-ffff-ffffffffffff"> | |
<Package InstallerVersion="200" | |
Compressed="yes" | |
InstallScope="perMachine" | |
Languages="1041" | |
SummaryCodepage="932" /> | |
<MajorUpgrade DowngradeErrorMessage="[ProductName] の新しいバージョンが既にインストールされています。" /> | |
<MediaTemplate EmbedCab="yes" /> | |
<!-- プログラムの追加と削除に関するエントリー | |
https://www.firegiant.com/wix/tutorial/com-expression-syntax-miscellanea/add-or-remove-programs-entries/ | |
--> | |
<Property Id="ARPNOREPAIR" Value="yes" Secure="yes" /> | |
<Property Id="ARPNOMODIFY" Value="yes" Secure="yes" /> | |
<!-- Directory Structure --> | |
<Directory Id="TARGETDIR" Name="SourceDir"> | |
<Directory Id="$(var.PlatformProgramFilesFolder)"> | |
<Directory Id="CompanyFolder" Name="OyatsuCompany"> | |
<Directory Id="INSTALLDIR" Name="foo"> | |
<Directory Id="BinFolder" Name="bin" /> | |
<Directory Id="IncludeFolder" Name="include" /> | |
<Directory Id="LibFolder" Name="lib" /> | |
</Directory> | |
</Directory> | |
</Directory> | |
</Directory> | |
<!-- デフォルトのインストール先を環境変数に基づいて変更する。 | |
機能がインストールされておらず、かつ XYZ_HOME が設定されている場合に限り、 | |
%XYZ_HOME%\foo をデフォルトのインストール先に設定する。 | |
--> | |
<SetProperty Id="INSTALLDIR" Value="[%XYZ_HOME]\foo" After="LaunchConditions" Sequence="first"> | |
<![CDATA[NOT Installed AND %XYZ_HOME <> ""]]> | |
</SetProperty> | |
<!-- Components --> | |
<!-- コンポーネントについて | |
コンポーネントはインストールを構成する最小単位である。 | |
そのため、多くはファイルやレジストリエントリごとに異なるコンポーネントを作成する。 | |
各コンポーネントは一意な GUID を持つ。互いに重複しないように注意する。 | |
ユーザーからは通常意識されない単位である。 | |
本インストーラーは x86 ビルドでは 32 bit ファイルだけを、 | |
x64 ビルドでは 64 bit ファイルだけを保持し、Program Files にインストールする。 | |
同一のパスに対して複数のコンポーネントを持つことはできない。 | |
そのため、プリプロセッサによって、同梱すべきコンポーネントをコンパイル時に選別する。 | |
--> | |
<DirectoryRef Id="BinFolder"> | |
<?if $(var.Platform) = x64 ?> | |
<Component Id="sampledll.dll" Win64="yes" Guid="YOURGUID-ffff-ffff-ffff-ffffffffffff"> | |
<File Id="sampledll.dll" Name="sampledll.dll" Source="source\bin64\sampledll.dll" KeyPath="yes" /> | |
</Component> | |
<?else ?> | |
<Component Id="sampledll.dll" Guid="YOURGUID-ffff-ffff-ffff-ffffffffffff"> | |
<File Id="sampledll.dll" Name="sampledll.dll" Source="source\bin\sampledll.dll" KeyPath="yes" /> | |
</Component> | |
<?endif?> | |
<Component Id="PathEnvToBin" Guid="YOURGUID-ffff-ffff-ffff-ffffffffffff"> | |
<CreateFolder /> | |
<Environment Id="PathEnvToBin" Name="PATH" Action="set" Part="last" System="yes" Value="[BinFolder]" Permanent="no" /> | |
</Component> | |
</DirectoryRef> | |
<DirectoryRef Id="IncludeFolder"> | |
<Component Id="sampledll.h" Guid="YOURGUID-ffff-ffff-ffff-ffffffffffff"> | |
<File Id="sampledll.h" Name="sampledll.h" Source="source\include\sampledll.h" KeyPath="yes" /> | |
</Component> | |
</DirectoryRef> | |
<DirectoryRef Id="LibFolder"> | |
<?if $(var.Platform) = x64 ?> | |
<Component Id="sampledll.lib" Win64="yes" Guid="YOURGUID-ffff-ffff-ffff-ffffffffffff"> | |
<File Id="sampledll.lib" Name="sampledll.dll" Source="source\bin64\sampledll.dll" KeyPath="yes" /> | |
</Component> | |
<?else ?> | |
<Component Id="sampledll.lib" Guid="YOURGUID-ffff-ffff-ffff-ffffffffffff"> | |
<File Id="sampledll.lib" Name="sampledll.dll" Source="source\bin\sampledll.dll" KeyPath="yes" /> | |
</Component> | |
<?endif?> | |
</DirectoryRef> | |
<!-- Start Menu Shortcuts --> | |
<!-- Features --> | |
<!-- 機能について | |
機能は、カスタムインストールの際に個別にインストールの有無を選択できる。 | |
機能の内訳はコンポーネントによって構成される。 | |
機能間の依存関係の定義はないが、Condition によって実現できる。 | |
主要な属性は下記のとおりである。 | |
Level | |
: 1=通常および完全インストールの対象, 1000=完全インストールの対象 | |
ConfigurableDirectory | |
: インストール先を選択可能にする。値は選択先パスを格納するプロパティ名(すべて大文字)。 | |
Display | |
: expand=機能ツリーの下位アイテムの表示を展開する | |
Absent | |
: disallow=インストール必須(「インストールしない」を削除) | |
AllowAdvertise | |
: no=「この機能は必要になったときにインストールされます」を削除 | |
--> | |
<Feature Id="XyzFeature" Title="Xyz ライブラリ" Description="XYZ 機能をインストールします。" Display="expand" AllowAdvertise="no" Absent="disallow" ConfigurableDirectory="INSTALLDIR"> | |
<Feature Id="XyzMainFeature" Title="基本機能" Description="XYZ 機能の実行モジュールをインストールします。" Level="1" AllowAdvertise="no"> | |
<ComponentRef Id="sampledll.dll" /> | |
</Feature> | |
<Feature Id="XyzAddPathEnv" Title="環境変数 PATH を設定" Description="XYZ 機能の実行可能ファイルのあるディレクトリを環境変数 PATH に追加します。" Level="1" AllowAdvertise="no"> | |
<ComponentRef Id="PathEnvToBin" /> | |
</Feature> | |
<Feature Id="XyzDevelopmentFeature" Title="ソフトウェア開発キット" Description="XYZ 機能を利用するアプリケーションの開発に必要なファイルをインストールします。" Level="1000" AllowAdvertise="no"> | |
<ComponentRef Id="sampledll.lib" /> | |
<ComponentRef Id="sampledll.h" /> | |
</Feature> | |
</Feature> | |
<!-- User Interface --> | |
<UI> | |
<!-- 基本とする UI のタイプを指定 --> | |
<UIRef Id="WixUI_FeatureTree" /> | |
<!-- エラーメッセージやプログレスバーの表示を追加 --> | |
<UIRef Id="WixUI_ErrorProgressText" /> | |
<!-- 使用承諾契約書ダイアログをスキップする --> | |
<!-- WixUI_Mondo の場合 | |
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="SetupTypeDlg" Order="3">1</Publish> | |
<Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="3">1</Publish> | |
--> | |
<!-- WixUI_FeatureTree の場合 --> | |
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="CustomizeDlg" Order="3">1</Publish> | |
<Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="3">1</Publish> | |
</UI> | |
</Product> | |
</Wix> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment