前回の記事、WiXをインストールせずに使うの解説編です。どうやって答えに辿り着いたかを書きます。

まず、適当なコンピュータにWiXをインストールして、1つWiXプロジェクトを作ります。作ったら、拡張子.wixprojのプロジェクトファイルをテキストエディタで開いてみます。

Visual Studioプロジェクトの.*projファイルはすべてMSBuildファイル形式です。すなわち、適当にMSBuildについてググったり本家のMSBuild リファレンスを読んだりしつつで理解できるはずのものになっています。

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
    <ProductVersion>3.7</ProductVersion>
    <ProjectGuid>{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}</ProjectGuid>
    <SchemaVersion>2.0</SchemaVersion>
    <OutputName>SetupProject1</OutputName>
    <OutputType>Package</OutputType>
    <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
    <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
    <OutputPath>bin\$(Configuration)\</OutputPath>
    <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
    <DefineConstants>Debug</DefineConstants>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
    <OutputPath>bin\$(Configuration)\</OutputPath>
    <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="Product.wxs" />
  </ItemGroup>
  <Import Project="$(WixTargetsPath)" />
  <!--
	To modify your build process, add your task inside one of the targets below and uncomment it.
	Other similar extension points exist, see Wix.targets.
	<Target Name="BeforeBuild">
	</Target>
	<Target Name="AfterBuild">
	</Target>
	-->
</Project>

とりあえず、ファイル内をWiXで検索すると、2ヶ所見つかります。PropertyGroup内のWixTargetsPathの定義と<Import Project="$(WixTargetsPath)" />です。Importは指定したファイルを取り込む要素なので、WixTargetsPathの定義がどうなっているかという問題になります。

<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>

MSDNライブラリの方法 : ビルドで環境変数を使用するにある「プロパティに既定値を設定するには」を少し変形したようなコードです。WixTargetsPathが定義されていなければ、デフォルトの場所にあるWix.targetsを指定するものであることが分かります。

というわけで、まずはこれを指定してビルドしてみます。すると失敗になりました。

D:\…>msbuild SetupProject1.sln /p:WixTargetsPath=D:\wix39-binaries\wix.targets
  D:\wix39-binaries\wix2010.targets(2025,5): error MSB4062: "GenerateCompileWithObjectPath" タスクをアセンブリ \WixTasks.dll から読み込めませんでした。ファイルまたはアセンブリ 'file:///d:\WixTasks.dll'、またはその依存関係の 1 つが読み込めませんでした。指定されたファイルが見つかりません。 <UsingTask> 宣言が正しいこと、アセンブリとその依存関係が使用可能であること、および Microsoft.Build.Framework.ITaskを実装するパブリック クラスがタスクに含まれていることを確認してください。 [D:\…\SetupProject1\SetupProject1.wixproj]

エラーメッセージに書かれているwix2010.targetsを開き、2025行目を見てみます。

<GenerateCompileWithObjectPath
    Compile="@(Compile)"
    IntermediateOutputPath="$(IntermediateOutputPath)">
  <Output TaskParameter="CompileWithObjectPath" ItemName="_CompileWithObjectPath" />
</GenerateCompileWithObjectPath>

が、ちょっとここは直接の原因ではなさそうでした。そこで、エラーメッセージを読み直してみると、“\WixTasks.dll”に怪しさを感じます。wix39-binariesフォルダにWixTasks.dllがあるので、ここへのパスが正しく設定されていないのではないかという予感です。

wix2010.targetsをWixTasks.dllで検索すると、最初のほうにこんなところが見つかりました。当たりです。

<!--
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
Extension Points
//////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////
-->
 
(途中省略)
 
<!-- These properties can be overridden to support non-default installations. -->
<PropertyGroup>
  <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
  <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
  <WixTasksPath Condition=" '$(WixTasksPath)' == '' ">$(WixInstallPath)\WixTasks.dll</WixTasksPath>
  <LuxTargetsPath Condition=" '$(LuxTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Lux.targets</LuxTargetsPath>
  <LuxTargetsPath Condition=" '$(LuxTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Lux.targets</LuxTargetsPath>
  <LuxTasksPath Condition=" '$(LuxTasksPath)' == '' ">$(WixInstallPath)\LuxTasks.dll</LuxTasksPath>
</PropertyGroup>

最終的にWixTasksPathが$(WixInstallPath)\WixTasks.dllと定義されるため、WixInstallPathにD:\wix39-binariesを定義しておけばよさそうです。

こうして前回書いたコマンドに行き着きました。

msbuild SetupProject1.sln ^
  /p:WixTargetsPath=D:\wix39-binaries\wix.targets ^
  /p:WixInstallPath=D:\wix39-binaries

スポンサード リンク

この記事のカテゴリ

  • ⇒ WiXをインストールせずに使う方法を見つけるまで
  • ⇒ WiXをインストールせずに使う方法を見つけるまで