【WP7 for IT Pro】Identity Developer Training Kit の前提条件チェックが通らないときの対処

2011年7月より UX & Client Platform Evangelism Group に転属となりました。今後ともよろしくお願いいたします。

早速ですが新部署移動後、最初の投稿は、Windows Phone 7(WP7)用の Identity Developer Training Kit の日本語環境での非互換についてです。

Identity Developer Training Kit(ITK) は、Identity 周りのテクノロジーの実装方法を Step by Step で習得できるプログラマー向けのコンテンツです。あいにく英語なのですが、Step by Step なのでさほど難しくありません。

Identity Developer Training Kit(ITK)2011年4月版(英語)

Visual Studio を使用するため(ExpressでもOK)、IT Pro には少々敷居が高いのですが、マイクロソフトがサポートする Identity 系テクノロジーのアーキテクチャを理解するのにとても Good なコンテンツなのです。なので、私も無理して Visual Studio を使用しています。

ITK 2011年4月版には、全部で9つのシナリオが用意されており、その中の1つに Windows Phone 7 と Windows Azure AppFabric ACS を使用するシナリオがあります。このシナリオは、Windows Azure 上の WEBサービスを Windows Phone 7上のアプリから使用するに当たり、Windows Azure AppFabric ACS からセキュリティトークンを発行してもらう...というものです。

image

シナリオを学習するには、セットアップスクリプトを実行する必要があるのですが、そのまえに「依存関係チェッカー(Dependencies.dep)」と呼ばれるプログラムを実行しなければなりません。

依存関係チェッカーを実行すると、以下のように当該シナリオに必要なコンポーネントがインストールされているかどうかがチェックされます。以下の例の場合、「Microsoft Windows Phone 7 Add-in for Visual Studio 2010」がインストールされないというエラーが表示されていることがわかります。

image

本当にインストールされていない場合には「Download」をクリックしてコンポーネントをインストールすれば済むのですが、これが何度インストールしてもチェックを通過することができません。コントロールパネルで確認すると、以下のようにインストールされていることがわかります。

image

これは明らかに依存関係チェッカーの動作ミスに違いありません。

ということで、依存関係チェッカー(Dependencies.dep)を確認してみます。

Dependencies.dep をメモ帳で開くと以下の通りです。ちょっと長いですが、ずらずらっと眺めてみてください。なんとなく、何がしたいかはわかりますよね。

<?xml version="1.0" encoding="utf-8" ?> <DependencyCheckerConfiguration> <title>Access Control and Windows Phone 7</title> <previews> <preview name="Check dependencies" description="Check prerequisites for Authenticating Users in a Windows Phone 7 App via Access Control Service, OData Services and Windows Azure Lab"></preview> <preview name="Setup database" description="Setup database schema and sample data"></preview> <preview name="Install code snippets" description="Install Visual Studio 2010 Code Snippets for the lab"></preview> </previews> <tasks> <task description="Setup database" scriptName=".\Scripts\SetupDb.cmd" displayConsole="true" /> <task description="Install Visual Studio 2010 Code Snippets for the lab" scriptName=".\Scripts\InstallCodeSnippets.cmd" displayConsole="true" /> </tasks>

  <dependencies> <os type="Vista" buildNumber="6000;6001"> <dependency value=".\Scripts\Dependencies\Check\CheckVistaSp2.ps1" enabled="true" optional="false" title="Vista SP2" explanation="Vista Service Pack 2 is required." scriptName="" downloadUrl="https://windows.microsoft.com/en-US/windows/downloads/service-packs" /> </os> <os type="Vista;Server" buildNumber="6002;7600;7601"> <dependency value=".\Scripts\Dependencies\Check\CheckVS2010.ps1" enabled="true" optional="false" title="Microsoft Visual Studio 2010" explanation="Install Microsoft Visual Studio 2010" scriptName="" downloadUrl="https://go.microsoft.com/fwlink/?LinkId=128752" /> <dependency value=".\Scripts\Dependencies\Check\CheckNET4.ps1" enabled="true" optional="false" title="Microsoft .NET Framework 4" explanation="Download and install the Microsoft .NET Framework 4" scriptName="" downloadUrl="https://www.microsoft.com/downloads/details.aspx?FamilyId=AB99342F-5D1A-413D-8319-81DA479AB0D7"/> <dependency value=".\Scripts\Dependencies\Check\CheckSqlServer.ps1" enabled="true" optional="true" title="Microsoft SQL Server Express 2008 (or later)" explanation="Install Microsoft SQL Server Express 2008 (or later)" scriptName="" downloadUrl="https://www.microsoft.com/express/sql/download/"/> <dependency value=".\Scripts\Dependencies\Check\CheckIIS7.ps1" enabled="true" optional="false" title="Microsoft IIS 7.0" explanation="Enable the Internet Information Services 7 feature." scriptName="Scripts\Dependencies\Setup\install-iis.bat" /> <dependency value=".\Scripts\Dependencies\Check\CheckIis7AspNet.ps1" enabled="true" optional="false" title="IIS7 ASP.NET" explanation="Enable the ASP.NET role." scriptName="Scripts\Dependencies\Setup\install-iis7aspnet.bat" /> <dependency value=".\scripts\dependencies\check\CheckAzureTools14ForVS2010.ps1" enabled="true" optional="false" title="Windows Azure SDK and Windows Azure Tools for Microsoft Visual Studio (March 2011)" explanation="Download and install Windows Azure SDK 1.4 and VS Tools" downloadUrl="https://go.microsoft.com/fwlink/?LinkId=128752"             scriptName=""/>

   <dependency value=".\scripts\dependencies\check\CheckWP7Emulator.ps1" enabled="true" optional="false" title="Microsoft Windows Phone Developer Emulator" explanation="Download and Install Windows Phone Developer Tools" scriptName="" downloadUrl="https://www.microsoft.com/downloads/en/details.aspx?FamilyID=04704acf-a63a-4f97-952c-8b51b34b00ce" /> <dependency value=".\scripts\dependencies\check\CheckWP7AddInVS2010.ps1" enabled="true" optional="false" title="Microsoft Windows Phone 7 Add-in for Visual Studio 2010" explanation="Download and Install Windows Phone Developer Tools" scriptName="" downloadUrl="https://www.microsoft.com/downloads/en/details.aspx?FamilyID=04704acf-a63a-4f97-952c-8b51b34b00ce" /> <dependency value=".\scripts\Dependencies\Check\CheckWifRuntime.ps1" enabled="true" optional="false" title="Windows Identity Foundation Runtime" explanation="Identity Labs require Windows Identity Foundation Runtime" scriptName="" downloadUrl="https://support.microsoft.com/kb/974405" />

        <dependency value=".\scripts\Dependencies\Check\CheckWifSdk4.ps1" enabled="true" optional="false" title="Microsoft Windows Identity Foundation SDK" explanation="Identity Labs require Windows Identity Foundation SDK" scriptName="" downloadUrl="https://www.microsoft.com/downloads/details.aspx?familyid=C148B2DF-C7AF-46BB-9162-2C9422208504" /> </os> </dependencies> </DependencyCheckerConfiguration>

黄色でマークした部分が、「Windows Phone 7 Add-in for Visual Studio 2010」のチェック部分です。目を凝らしてみると、

.\scripts\dependencies\check\CheckWP7AddInVS2010.ps1

という PowerShell スクリプトが呼ばれていることがわかります。

...ということで、CheckWP7AddInVS2010.ps1 を見てみましょう。

C:\IdentityTrainingKitVS2010\Assets\DependencyChecker\scripts\dependencies\check の配下に格納されている CheckWP7AddInVS2010.ps1 を開くと以下の通りです。

function SearchAllUninstallKeys($SearchFor, $Version) { $os = Get-WMIObject win32_operatingsystem [bool] $found = $False; $SearchFor64bits = "$SearchFor (64-bit)" # Seach in uninstall folder $found = SearchUninstall -SearchFor $SearchFor -UninstallKey 'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' -Version $Version; if($found) {return $found;} #Search in 64 bit keys folders if ($os.OSArchitecture -eq "64-bit") { #Wow folder $found = SearchUninstall -SearchFor $SearchFor -UninstallKey 'HKLM:SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\' -Version $Version; if($found) {return $found;} #Wow folder, 64 bits $found = SearchUninstall -SearchFor $SearchFor64bits -UninstallKey 'HKLM:SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\'-Version $Version; if($found) {return $found;} #32bit folder, 64 bits $found = SearchUninstall -SearchFor $SearchFor64bits -UninstallKey 'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\'-Version $Version; if($found) {return $found;} } return $found; }

SearchAllUninstallKeys -SearchFor 'Windows Phone 7 Add-in for Visual Studio 2010 - ENU' -Version '10.0.30319';

一番下の行を見てください。 -Version '10.0.30319' という記述が見えます。明らかにバージョン番号であることがわかりますね。この番号をコントロールパネルに表示された値と比較すると...合ってる。バージョン番号に問題はありません。

ではどこがおかしいのか...?

英語版のスクリプトをデバッグする場合には、文字列比較している部分を疑うのがコツです。ここで一番怪しいのは、黄色くマークした部分です。

if ($os.OSArchitecture -eq "64-bit") {

OSのアーキテクチャが “64-bit” の場合には...という判定をしているっぽい記述ですよね。かなり臭いです。

そこで、PowerShell のコンソールを開いて、以下のコマンドを入力してみてください。

PS C:\Windows\system32> $os = Get-WMIObject win32_operatingsystem PS C:\Windows\system32> $os.OSArchitecture 64 ビット

なんと、OSArchitecture プロパティの値は「64 ビット」という日本語じゃないですか!

やってられーん...こともない!ということで、スクリプトを書き換えましょう。

if ($os.OSArchitecture -eq "64-bit") {

↓以下のように書き換え

if ($os.OSArchitecture -eq "64 ビット") {

保存して、再度依存関係チェッカーを実行すると、以下の通り正常終了します。

image

Identity Developer Training Kit を使用する場合には、以下も参考にしてください。

【IDM】Identity Developer Training Kit がうまくインストールできないときの対処