VS 2005 allows you to create your own custom device cab files. It does many of the basic things that you would want in a cab: Add files, set registry values, create shortcuts. For many people this is all they really need in order to get an application installed on the device.
One handy feature of a Windows Mobile cab is being able to add provisioning XML to the _setup.xml. This provisioning XML gets sent to DMProcessConfigXML when the cab gets installed. VS 2005’s Smart Device Cab project doesn’t allow you to do this, so let me show you one way that you can!
In the process of creating a cab, VS leaves the .inf around. This is great because that is all you really need (and the contents of the cab, of course J) to recreate the cab file using cabwiz (the actual process responsible for generating the cab). So, we’ll do just that. We’ll call cabwiz again with the .inf file generated by VS, only this time, we’ll use cabwiz’s /postxml argument which allows us to pass in a snippet of XML that should be appended to the _setup.xml file included in the generated cab.
You can just manually call cabwiz from the command line after VS has generated your cab, but why do that when you can have VS manage that for you?
I have attached (see end of entry) the sample VS 2005 solution that shows how to add the provisioning XML to the cab. The sample will add an Internet Explorer favorite to the Windows Mobile site as well as install a sample application.
You can use any provisioning XML (for instance, the provisioning XML that adds the root cert mentioned in blog entry on Saturday the 28th. The cab would have to be signed trusted in this case). If you want to look more into DMProcessConfigXML and provisioning XML, visit the MSDN entry on DMProcessConfigXML.
The sample solution contains 3 projects:
SampleApplication: This is just a sample application so that we have something to install.
SampleProvXmlCab: This is the cab project. This is set up to install the above application and add a shortcut to the programs menu.
AddProvXml: This project is responsible for including the provisioning XML and is what I will explain further.
AddProvXml is a desktop makefile project. You can find it under the Visual C++ node in the Add New Project Dialog. When I created this project, I filled out the following settings in the project wizard:
In the Debug Configuration Settings:
Both the Build and Rebuild Command Line:
“$(VSInstallDir)SmartDevices\SDK\SDKTools\cabwiz.exe” “$(SolutionDir)SampleProvXmlCab\$(ConfigurationName)\SampleProvXmlCab.inf” /postxml “$(ProjectDir)post.xml”
I left the Release Configuration settings the same as the debug settings above.
The project contains one file, post.xml, which contains the XML snippet that I want to append to the cab’s _setup.xml.
Last, I set the AddProvXml project to have a dependency on the SampleProvXmlCab project just to make sure that the AddProvXml ran after the cab project. This is set in the Solution Properties under “Project Dependencies.”
Now, when ever you build, the custom makefile project (AddProvXml) will rebuild the cab that the cab project built (the cab will be located in the directory as the originally generated cab), with your XML appended to the _setup.xml. You can use this technique to take advantage of any of cabwiz’s command line options.
— Brian Cross
— Brian Cross