Welcome!

Microsoft Cloud Authors: Nick Basinger, Kevin Benedict, Pat Romanski, Liz McMillan, Lori MacVittie

Related Topics: Microsoft Cloud

Microsoft Cloud: Article

Packaging and Deploying .NET Compact Framework Solutions

Packaging and Deploying .NET Compact Framework Solutions

One of the great benefits of building applications that utilize the .NET Compact Framework is, of course, that the application is installed on the device so it can work in both disconnected and occasionally connected modes. But as with most things in IT, there is a trade-off lurking around the corner. In this case that trade-off is the packaging and deployment of the application. And so in this column we'll give you a rundown of the options you have and what Visual Studio .NET provides to make your life a little easier.

Packaging Made Easy
Before an application can be deployed to a device or set of devices, it must be packaged. Fortunately, VS.NET and Smart Device Projects (SDP) provide plenty of help in targeting the application to a specific directory on the device and building .cab files for deployment to devices supporting different processors.

First, however, before actually creating the .cab file it is important to note three basic features of VS.NET. First, you can set the Output File Folder property in the Properties window in VS.NET. This property (which defaults to Program Filesprojectname) specifies the deployment directory on the device that the project will be installed in and is referenced by the .cab file-creation process. Second, you can package and deploy project-related files (like SQL Server CE databases and configuration files) by setting their Build Action property to Content in the Properties window. And finally, you should change the build configuration from Debug to Release in order to produce smaller and faster assemblies.

Once the project options are set, a .cab file can be created to deploy the application. SDP makes this easy by including a Build Cab File menu, accessible by right-clicking the project. This process is different than in the desktop version of the .NET Framework, in which a deployment project that uses the Windows Installer can be added to the solution to package the application.

When this option is invoked, VS.NET silently creates a cab directory under the project directory on your workstation. In this directory and within a directory identifying the build mode (Debug or Release) is placed a series of .cab files. Each .cab file targets a specific processor type - including ARM, ARM4, MIPS, SH3, and X86 - and is named accordingly, e.g., MyApplication _PPC_ARM.CAB. To install the application on a device, the .cab file simply needs to be copied to the device. Windows CE includes software that automatically performs the unpacking and installation of .cab files.

In order to customize the installation process, SDP also adds the files needed to customize and rebuild the .cab files in the objuildmode directory. The BuildCab.bat, Dependencies_platform.txt, and Projectname_platform.inf files, along with a configuration file for each processor type, are placed in this directory. The batch file can be used to initiate the rebuild of the .cab files. The dependencies file contains the list of .cab files that the batch file is dependent on and always contains a reference to the Compact Framework .cab file for each processor type. At installation time these dependencies will be checked to ensure that they have been applied to the device. The .inf file contains the installation settings to use when the .cab file is executed. It is important to note that the .cab file created does not include the .cab file for the Compact Framework. Although Pocket PC 2003 devices ship with the Compact Framework in ROM, for the present you'll need to copy and execute the redistributable on the device.

To customize the installation on the device, the .inf can be modified. For example, you can add a shortcut to the Programs group on a Pocket PC by modifying the following sections in the .inf file like so:

[DefaultInstall]
CEShortcuts=Shortcuts

[Shortcuts]
My Application,0,myapp.exe,%CE2%Start MenuPrograms

Other examples of customizing the .inf file might include adding additional files (for example, SQLCE databases) to be distributed to the device in the .cab file by modifying the CopyFiles section.

Ready-Set-Deploy!
After a Compact Framework application has been packaged into a .cab file it can be deployed and installed on the device. You can do this in several ways, including the following:

  • ActiveSync: Perhaps the most obvious option for deploying a Compact Framework application is to allow the application to be installed when the device is cradled using the ActiveSync software typically used to synchronize files and e-mail.

    To do so the application must be registered with the ActiveSync Application Manager installed on the desktop machine. This process is relatively simple and requires creating a custom setup executable or an installer that integrates with a Windows Installer project created in VS.NET. In either case the process then invokes the Application Manager on the workstation with ActiveSync installed, passing it an .ini file that contains information about the application to be installed. For a complete example of how to do this, check out the whitepaper "Developing and Deploying Pocket PC Setup Applications" on the Microsoft Smart Devices Developer Community Site (http://smartdevices.microsoftdev.com).

    While this deployment and installation option is intuitive and provides a familiar mechanism to the user, it does require that the custom-setup application be installed on the workstation used for synchronizing with the device.

  • Web site: The second option is to use a Web site. Using this option an organization could create a public or intranet site that contains links to the various .cab files created by SDP. This option has the benefit of not requiring the device to be cradled in order to install software.

    When users navigate to the Web page using Pocket Internet Explorer, they can tap on the required .cab file. The resulting dialog allows the file to be downloaded and then opened. Opening the file after download is equivalent to executing the .cab file on the device and will cause the application to be installed.

    To protect the .cab files, especially on a site accessible over the Internet, it is recommended that the virtual directory in which the download page resides be protected by standard HTTP encryption and authentication schemes. There are also third-party solutions such as the Appear Provisioning Server (APS) from Appear Network, which allows automatic delivery, single-click download, and automatic discard of location-specific applications targeted for health care, hospitality, transportation, and workforce coordination.

  • Storage card: In many cases, the application needs to be deployed along with a SQL Server CE database or other software. As a result it can be both time consuming and bulky to deploy such an application over the Internet or through a cradled connection. For those reasons the application can alternatively be deployed on a memory storage card such as a Compact Flash card. However, rather than requiring the user to execute the .cab file once the storage card is inserted into the device, Pocket PC devices include an Autorun feature that can be utilized.

    With this feature, when a storage card is inserted into the device, the Pocket PC looks for an executable called Autorun.exe in a folder mapping to the processor type of the device. For example, if the processor type is ARM, then it will look for the file Storage CardARMAutorun.exe on the storage card. When found, the executable is copied to the Windows folder and executed with the install parameter. Likewise, when the card is removed from the device, the same executable is launched with the uninstall parameter.

  • File share: Just as with a Web site deployment, the .cab files can be placed on a local area network share and accessed wirelessly using 802.1x (or even through ActiveSync when cradled, using ActiveSync 3.5 and higher supporting pass-through) from the File Explorer on the device.

    And as with Web deployment, the share can be protected and users will be forced to enter valid credentials to gain access to the files. Once again, this option frees the user from having to cradle the device in order to install software.

  • Auto-deployment: Although slightly different from the previous deployment options, applications written in the Compact Framework, just as in the desktop .NET Framework, can be written to be auto-updating. By auto-updating, we mean an application that checks - either periodically or with each invocation - a file share or Web site for newer versions of its assemblies and then dynamically downloads the new assemblies. This technique is especially effective for applications that use private assemblies, since the application can be partitioned into various functionalities, each housed in a separate assembly and therefore updated independently.

    The obvious benefit to creating an auto-updating application is that it reduces the burden of keeping the application up to date. For an example of how such a component could be written, take a look at Microsoft's Updater Application Block at www.microsoft.com/patterns.

    It's Up to You
    Now that we've given you the options and set the stage, all that's left for you to do is the work. So get out there and deploy your Compact Framework applications!

  • More Stories By Jon Box

    Jon Box is an Architect Evangelist in Developer & Platform Evangelism with the Microsoft Corporation. He coauthored Building Solutions with the Microsoft .NET Compact Framework, published by Addison-Wesley, and blogs at http://blogs.msdn.com/jonbox/default.aspx.

    Comments (0)

    Share your thoughts on this story.

    Add your comment
    You must be signed in to add a comment. Sign-in | Register

    In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


    IoT & Smart Cities Stories
    The Japan External Trade Organization (JETRO) is a non-profit organization that provides business support services to companies expanding to Japan. With the support of JETRO's dedicated staff, clients can incorporate their business; receive visa, immigration, and HR support; find dedicated office space; identify local government subsidies; get tailored market studies; and more.
    At CloudEXPO Silicon Valley, June 24-26, 2019, Digital Transformation (DX) is a major focus with expanded DevOpsSUMMIT and FinTechEXPO programs within the DXWorldEXPO agenda. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of business. Only 12% still survive. Similar percentages are found throug...
    AI and machine learning disruption for Enterprises started happening in the areas such as IT operations management (ITOPs) and Cloud management and SaaS apps. In 2019 CIOs will see disruptive solutions for Cloud & Devops, AI/ML driven IT Ops and Cloud Ops. Customers want AI-driven multi-cloud operations for monitoring, detection, prevention of disruptions. Disruptions cause revenue loss, unhappy users, impacts brand reputation etc.
    Atmosera delivers modern cloud services that maximize the advantages of cloud-based infrastructures. Offering private, hybrid, and public cloud solutions, Atmosera works closely with customers to engineer, deploy, and operate cloud architectures with advanced services that deliver strategic business outcomes. Atmosera's expertise simplifies the process of cloud transformation and our 20+ years of experience managing complex IT environments provides our customers with the confidence and trust tha...
    At CloudEXPO Silicon Valley, June 24-26, 2019, Digital Transformation (DX) is a major focus with expanded DevOpsSUMMIT and FinTechEXPO programs within the DXWorldEXPO agenda. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of business. Only 12% still survive. Similar percentages are found throug...
    At CloudEXPO Silicon Valley, June 24-26, 2019, Digital Transformation (DX) is a major focus with expanded DevOpsSUMMIT and FinTechEXPO programs within the DXWorldEXPO agenda. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of business. Only 12% still survive. Similar percentages are found throug...
    As you know, enterprise IT conversation over the past year have often centered upon the open-source Kubernetes container orchestration system. In fact, Kubernetes has emerged as the key technology -- and even primary platform -- of cloud migrations for a wide variety of organizations. Kubernetes is critical to forward-looking enterprises that continue to push their IT infrastructures toward maximum functionality, scalability, and flexibility. As they do so, IT professionals are also embr...
    In his general session at 19th Cloud Expo, Manish Dixit, VP of Product and Engineering at Dice, discussed how Dice leverages data insights and tools to help both tech professionals and recruiters better understand how skills relate to each other and which skills are in high demand using interactive visualizations and salary indicator tools to maximize earning potential. Manish Dixit is VP of Product and Engineering at Dice. As the leader of the Product, Engineering and Data Sciences team at D...
    As you know, enterprise IT conversation over the past year have often centered upon the open-source Kubernetes container orchestration system. In fact, Kubernetes has emerged as the key technology -- and even primary platform -- of cloud migrations for a wide variety of organizations. Kubernetes is critical to forward-looking enterprises that continue to push their IT infrastructures toward maximum functionality, scalability, and flexibility.
    Today's workforce is trading their cubicles and corporate desktops in favor of an any-location, any-device work style. And as digital natives make up more and more of the modern workforce, the appetite for user-friendly, cloud-based services grows. The center of work is shifting to the user and to the cloud. But managing a proliferation of SaaS, web, and mobile apps running on any number of clouds and devices is unwieldy and increases security risks. Steve Wilson, Citrix Vice President of Cloud,...