Partager via


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)\SampleProvXmlCab.cab"

 

Output:

"$(SolutionDir)SampleProvXmlCab\$(ConfigurationName)\SampleProvXmlCab.cab"

 

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

SampleApplication.zip

Comments

  • Anonymous
    February 10, 2006
    TGIF!  (sort of..  I'll be working through the weekend yet again..sigh).   Oh yeah,...

  • Anonymous
    April 21, 2006
    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.

  • Anonymous
    April 21, 2006
    Great! I'm glad that it worked out for you!

  • Anonymous
    May 01, 2006
    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.

  • Anonymous
    September 25, 2006
    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.

  • Anonymous
    November 12, 2006
    The comment has been removed

  • Anonymous
    November 16, 2006
    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. THX, GG

  • Anonymous
    November 17, 2006
    Hi Gustavo - good question. There's not currently any public API to interface with ConfigManager2.

  • Anonymous
    March 26, 2007
    <a href=' http://filmdvd.jedo.info/any-download-movie.html '>any download movie</a>

  • Anonymous
    August 05, 2007
    There was a question in the forums, if there is a way to configure a network adapter automatically -

  • Anonymous
    March 09, 2008
    Many developers know (or should know) the bedrock principle of software development: &quot; KNOW THY

  • Anonymous
    July 15, 2008
    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?

  • Anonymous
    November 07, 2008
    <a href='http://ozcelik.com.tr/images/_notes/pic/errota-1887.html'>new release movie reviews</a> <a href="http://ozcelik.com.tr/images/_notes/pic/errota-1887.html">new release movie reviews</a> [link=http://ozcelik.com.tr/images/_notes/pic/errota-1887.html]new release movie reviews[/link]

  • Anonymous
    November 13, 2008
    <a href='http://tourismcollege-varna.com/images/articles/pics/bugmon.html'>tv food recipes</a> <a href="http://tourismcollege-varna.com/images/articles/pics/bugmon.html">tv food recipes</a> [link=http://tourismcollege-varna.com/images/articles/pics/bugmon.html]tv food recipes[/link]