Injecting Provisioning XML into a cab using VS 2005

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"


Clean Commands:

del "$(SolutionDir)SampleProvXmlCab\$(ConfigurationName)\"





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

Comments (14)

  1. Nino.Mobile says:

    TGIF!  (sort of..  I’ll be working through the weekend yet again..*sigh*).   Oh yeah,…

  2. ajh says:

    Thanks very much for this!  It works like a charm!

    After reading the msdn link, I realized that I could include dialup-networking entries during my install.  This has saved me HOURS of work writing in import utility for RAS entries.

  3. BCross says:

    Great! I’m glad that it worked out for you!

  4. Erik says:

    When opening the project  – the AddProvXML.vcproj is not loaded. It says the file is not installed.

    Any good ideas to get this to work.

  5. kworam says:

    I have a Smart Device CAB Project in VS 2005 that builds an installer CAB for my C#, .NET Compact Framework 2.0 SP1 application.  The Smart Device CAB Project contains the Primary Output from my application’s User Inteface project.  

    Recently, the CAB Project stopped getting the latest output from my User Interface project.  In other words, even though I had made bug fixes to my User Interface project and re-built it, the CAB project was still holding onto the old DLLs and EXEs that did not contain the bug fixes.   I spent a frustrating day trying to figure out why my latest bug fixes worked fine on the Pocket PC Emulator, but did not work when I installed them on ‘real’ devices.  When I discovered the problem, I deleted the User Interface ‘Primary Output’ from my Installer CAB and then re-added it.  This fixed the problem (for now) but I’m not sure when or if it might crop up again.  Is this a known problem?

    This is by no means the only bug I have found in VS 2005.  I am eagerly awaiting a VS2005 Service Pack, it badly needs it.

  6. Nir says:

    I have to do some cleanup stuff on uninstall. So I added a call to DMProcessConfigXML on the DllUnregisterServer() of my component.

    This causes the uninstall to freeze although msdn says its okay.

    So maybe the better option is to add the Provisioning XML to the uninstall.

    your nice article talks about adding Provisioning XML on install time – can you fill me the gap for uninstall?

  7. Gustavo Garcia says:

    Hi Brian,

    DMProcessConfigXML() API gives access to Configuration Manager, therefore accepting only WAP-XML format. Is there any API to make use of Configuration Manager2 that may process OMA-DM 1.2 XML format?? This would provide local access to all the new CSP’s.



  8. scyost says:

    Hi Gustavo – good question. There’s not currently any public API to interface with ConfigManager2.

  9. There was a question in the forums, if there is a way to configure a network adapter automatically –

  10. Many developers know (or should know) the bedrock principle of software development: " KNOW THY

  11. Dan Olsen says:

    Thanks.  This worked like a charm in VS 2008 too.  

    Anyone know if the capabilities of the cab file project will ever be enhanced to allow this kind of customization directly?

Skip to main content