Using CapDetect Tool in Windows Phone 7

CapDetect is a recently added Windows Phone 7 Developer Tool; it is in the Developer Tools January 2011 Patch.

What does it do?

It edits your WMManifest.xml file according to your application's needs.

CapDetect is a rule-based command line utility that uses an XML file as a "rule file" and takes output of your project or XAP file as a "file path" parameter. If you provide an output folder then it automatically finds the XAP file.

Use of this utility is as:

CapabilityDetection  <rules path> <file path>

The location of this tool is:

For 32 bit users ->   %ProgramFiles%\Microsoft SDKs\Windows Phone\v7.0\Tools\CapDetect
For 64 bit users ->   %ProgramFiles (x86)%\Microsoft SDKs\Windows Phone\v7.0\Tools\CapDetect

Let's use it:

Assuming you have already created a new project and then debugged (XNA or Silverlight doesn't matter).

The first thing you need to do is to run your command prompt and get to the location of CapDetect tool as I described above.

Then write this type of command line:

 CapabilityDetection Rules.xml "C:\Users\iersoy\Desktop\WindowsPhoneGame2\WindowsPhoneGame2
\WindowsPhoneGame2\bin\WindowsPhone\Debug"


You will need to change the path according to your own application.


Remind one thing!

You need to use quotation marks (") before and after writing [file path]


Before using this tool I had a WMManifest file just like:

 <?xml version="1.0" encoding="utf-8" ?>
<Deployment xmlns="http://schemas.microsoft.com/
windowsphone/2009/deployment"AppPlatformVersion="7.0">
<App xmlns="" ProductID="{bfd638f3-4ca0-4043-9871-d34bc559eeb6}"
Title="WindowsPhoneGame2"
RuntimeType="XNA" Version="1.0.0.0" Genre="Apps.Normal"
Author="" Description="" Publisher="">
<IconPath IsRelative="true" IsResource="false"></IconPath>
<Capabilities>
<Capability Name="ID_CAP_NETWORKING" />
<Capability Name="ID_CAP_LOCATION" />
<Capability Name="ID_CAP_SENSORS" />
<Capability Name="ID_CAP_PUSH_NOTIFICATION" />
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />
<Capability Name="ID_CAP_IDENTITY_USER" />
<Capability Name="ID_CAP_IDENTITY_DEVICE" />
</Capabilities>
<Tasks>
<DefaultTask Name="_default"/>
</Tasks>
<Tokens>
<PrimaryToken TokenID="WindowsPhoneGame2Token" TaskName="_default">
<TemplateType5>
<BackgroundImageURI IsRelative="true" IsResource="false">
</BackgroundImageURI>
<Count>0</Count>
<Title></Title>
</TemplateType5>
</PrimaryToken>
</Tokens>
</App>
</Deployment>


In the following some capabilities are missing because I have deleted 4 Capabilities from my application:

 <Capability Name="ID_CAP_MICROPHONE" />
 <Capability Name="ID_CAP_MEDIALIB" />
 <Capability Name="ID_CAP_GAMERSERVICES" />
 <Capability Name="ID_CAP_PHONEDIALER" />


But the tool has re-added the Capabilities and made some changes in Manifest file inside XAP package.

<?xml version="1.0" encoding="utf-8"?>
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment"
AppPlatformVersion="7.0">
<App xmlns="" ProductID="{bfd638f3-4ca0-4043-9871-d34bc559eeb6}"
Title="WindowsPhoneGame2"
RuntimeType="XNA" Version="1.0.0.0" Genre="Apps.Normal"
Author="" Description="" Publisher="">
<IconPath IsRelative="true" IsResource="false">
GameThumbnail.png</IconPath>
<Capabilities>
<Capability Name="ID_CAP_NETWORKING" />
<Capability Name="ID_CAP_LOCATION" />
<Capability Name="ID_CAP_SENSORS" />
<Capability Name="ID_CAP_MICROPHONE" />
<Capability Name="ID_CAP_MEDIALIB" />
<Capability Name="ID_CAP_GAMERSERVICES" />
<Capability Name="ID_CAP_PHONEDIALER" />
<Capability Name="ID_CAP_PUSH_NOTIFICATION" />
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />
<Capability Name="ID_CAP_IDENTITY_USER" />
<Capability Name="ID_CAP_IDENTITY_DEVICE" />
</Capabilities>
<Tasks>
<DefaultTask Name="_default" />
</Tasks>
<Tokens>
<PrimaryToken TokenID="WindowsPhoneGame2Token" TaskName="_default">
<TemplateType5>
<BackgroundImageURI IsRelative="true" IsResource="false">
Background.png</BackgroundImageURI>
<Count>0</Count>
<Title>WindowsPhoneGame2</Title>
</TemplateType5>
</PrimaryToken>
</Tokens>
</App>
</Deployment>



This is a very useful command line utility for testing your application before sending it to the MarketPlace.

Hope you like it too!



Similar Articles