Smartphone 2003应用程序的打包安装

2024-02-21 08:08

本文主要是介绍Smartphone 2003应用程序的打包安装,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

它的原理非常简单,就是调用CabWizSP.exe生成CAB包(需要手动写inf文件),然后调用一个第三方的ezsetup.exe工具来生成安装文件,在建立与Smartphone(真机or模拟器)连接之后执行自动安装。

Windows Mobile-based Smartphone Applications Deployment Demystified

Microsoft

February 2004

Applies to:
   Microsoft® .NET Compact Framework
   Windows Mobile-based Smartphones
   Windows Mobile 2003 Second Edition software for Smartphones
   Microsoft Visual Studio® .NET 2003

Summary: Discussion surrounds deployment options for mobile applications built using the .NET Compact Framework. We'll concentrate on the use of CabWizSP.exe, the command line tool used to bundle a redistributable file for end users of your application. (7 printed pages)

Download Smartphone 2003 Deployment.msi from the Microsoft Download Center.

Contents

Introduction to Deployment on Smartphones
First Things First
Let's Get to Work!?!
Putting It All Together
A Walkthrough
Wrap-up

Introduction to Deployment on Smartphones

Mobile operators are already introducing Windows Mobile™ 2003 software for Smartphones. This provides an exciting opportunity to build and deploy applications for a new form factor device.

For Microsoft® Visual Studio® .NET 2003 developers, this paper helps you understand how to support deployment to a Smartphone device. The focus will be on the process to create a cabinet file for distribution to Smartphone devices using CabWizSP.exe. Additionally, though it is possible to deploy custom-built applications to an 'Operator Locked' device, this should not be done without some preparation.

First Things First

To understand Smartphone application deployment, you need to be aware of the security execution model under which Smartphone applications run. Each wireless carrier has the ability with Windows Mobile software for Smartphone to customize the security execution environment of devices running on their specific network. The scenario could easily exist where an application may install and execute on a device on one carrier's network while a similar device on another carrier's network has a much more restrictive security policy and the application execution would fail or quite possibly not even install.

There are 3 basic configurations in the security model in Windows Mobile software for Smartphones: Unrestricted, Restricted, and Standard.

  • Unrestricted Applications install and run on the device regardless of whether they are signed.
  • Restricted Signed applications install and run while unsigned applications neither install nor run.
  • Standard — Applications that are signed with a certificate install and run without a prompt. Applications that are not signed will still install and run, but the user is prompted in each case.

There is a developer's guide to the Smartphone security model on MSDN that includes information of the options available to a carrier for security policy, which additionally provides guidance on the configuration of your development environment.

If you're thinking about developing applications for Windows Mobile-based Smartphones, you should check out Mobile2Market, which provides a process that helps you take your Pocket PC and Smartphone applications to market.

Let's Get to Work!?!

Ok, let's face the facts. The build command available in Visual Studio .NET does not work well with the Smartphone SDK. The Smartphone 2003 SDK README does indeed point this out. If you're reading this article because you kept getting build errors on your Smartphone application when trying to create the CAB file, you are not alone. Guidance on fixing the files generated by the build command is provided in this MSDN article. This article focuses on building an installation from scratch. It is especially confusing because the Build command indeed does work for Pocket PC and Pocket PC Phone edition Microsoft .NET Compact Framework projects.

When you run the Build command, it generates a number of files. One of these files is buildcab.bat. The buildcab.bat file only contains a single line that makes a call to CabWizSP.exe. There is not much magic going on here. However the command line call to CabWizSP.exe can become so long it is quicker and less error prone to create a batch file rather than type a long command line. The batch file will make your life easier!

The Smartphone SDK installs CabWizSP.exe as part of its tools, which are typically installed to the folder C:/Program Files/Windows CE Tools/wce420/SMARTPHONE 2003/Tools. A sample buildcab.bat will look like this:

CabWizSP.exe AppName.inf /err CabWizSP.err.log /cpu ARMV4 X86

The BuildCab.bat file included with this article looks like this:

"D:/Program Files/Windows CE Tools/wce420/SMARTPHONE 
2003/Tools/CabwizSP.exe" "Magic 8 Ball_SMP.inf" /err CabWizSP.err.log

You will notice in the above calls several different command line parameters. There are actually seven different command line parameters available that could be used with CabWizSP.exe to create a cab file. Notice I am building Cab files for both the Smartphone and the Visual Studio emulator using the /cpu flag in the first example. I am also pushing any errors during Cab file creation to the file CabWizSP.err.log. This is in both examples.

The flags are quite self explanatory, however there is a table below that explains them. I would like to point out that you should generally not use the /nouninstall flag. You should always provide an easy way for the user to remove your program from their device. Users may access this dialog from within the Add/Remove Programs dialog box in ActiveSync®, via the menu path Tools -> Add/Remove Programs.

Table 1. CabWizSP.exe Flags*

FlagDescription
/destDestination directory for the .cab files. If no directory is specified, the .cab files are created in the same directory as the .inf file directory.
/errFile name for a log file that contains all warnings and errors that are encountered when the .cab files are compiled. If no file name is specified, errors are displayed in message boxes. If a file name is used, the CabWizSP.exe application runs without the user interface (UI); this is useful for automated builds.
/cpuCreates a .cab file for each cpu type that is specified. A cpu type is used in the.inf file to differentiate between processor types.
/platformCreates a .cab file for each platform label that is specified. A platform label is used in the .inf file to differentiate between different platform and processor types.
/prexmlFull path and file name to a valid XML file that contains Smartphone provisioning XML that is read by Configuration Manager. This /prexml file is added to the .cab _setup.xml file before the instructions in the .inf file.
/postxmlFull path and file name to a valid XML file that contains Smartphone provisioning XML that is read by Configuration Manager. This postxml file is added to the .cab file _setup.xml file after the instructions in the .inf file.
/nouninstallTells the Smartphone that it should not create an uninstall document for this .cab file. The .cab file will not receive an entry in the Remove Programs screen.

*Taken from Smartphone 2003 SDK Help

I'm not going to discuss pre and post provisioning of a Smartphone device either. They are better served by an article dedicated to Smartphone configuration and provisioning using XML that is achieved through using /prexml and /postxml. Also, I would like readers to be awake and alert upon finishing this document.

Putting It All Together

At this point we are almost ready to actually run the command, but wait, we need to discuss one last topic: how to create an appropriate .inf file for CabWizSP.exe consumption. The information file is very important because it is where you specify several different aspects of your application. It will contain not just metadata, but where to install you application on the device and which shortcuts to create so a user can actually use your program once they have installed it on their device.

Tables, tables, tables; there are quite a few tables in this discussion. It is valuable to have all the information in a single place rather than spending the afternoon, evening, and quite possibly the next few days in the Smartphone 2003 SDK help files. So in keeping with the tables theme, here are a few more tables. These tables are useful background for the installer walkthrough section that follows them.

Table 2. .inf File Sections*

SectionRequiredDescription
VersionYesThe application's version.
CEStringsYesString substitutions for application and directory names. The string must be in uppercase.
StringsNoString definitions for one or more strings.
CEDeviceYesThe device platform for which the application is targeted.
DefaultInstallYesThe default installation of the application.
SourceDisksNamesYesThe name and path of the disk on which the application resides.
SourceDisksFilesYesThe name and path of the files in which the application resides.
DestinationDirsYesThe names and paths of the destination directories for the application on the target device.
CopyFilesYesDefault files to copy to the target device.
AddRegNoKeys and values that the .cab file will add to the registry on the device.

Note: We recommend that installed applications use the HKCU/Software/ branch of the registry to store information.

CEShortCutsNoShortcuts the cab installer creates on the device upon installation of the application.
PlatformNoThe platform and the platform version number that is valid for selective installations.

* Taken from Smartphone 2003 SDK Help

Table 3. Windows CE® Strings for Smartphone*

IdentifierSmartphone Directory
%CE1%/Program Files
%CE2%/Windows
%CE11%/Windows/Start Menu/Programs
%CE14%/Windows/Start Menu/Programs/Games
%CE17%/Windows/Start Menu
%CE18%<default volume, dependent on device configuration>
%CE19%/Application Data

* Taken from Smartphone 2003 SDK Help

That's the end of the data tables, promise. There is one house cleaning fact left. In the previous table, the identifiers actually run %CE1% through %CE20%, those not in the table are not currently used in this release of the Smartphone SDK, but are reserved.

A Walkthrough

Now let's walk through a sample configuration file piece by piece:

[Version]
Signature="$Windows NT$"      ; required as-is
Provider="Microsoft"            ; max of 30 chars, cannot use XML reserved
chars CESignature="$Windows CE$" ; required as-is

The only part you may change is the Provider string value. You cannot have an empty string nor can you use any of the XML reserved characters like //:*?" < >|&. Also the string in Provider is concatenated with AppName in the CEStrings section.

[CEStrings]
AppName="Magic 8 Ball"      ; max of 40 chars, no XML reserved chars
InstallDir=%CE1%/%AppName%   ; Installation directory on device
[CEDevice]
VersionMin=4.00            ; required as-is
VersionMax=4.99            ; required as-is

In our example, since Provider is concatenated with AppName we will have the value "Microsoft Magic 8 Ball" show up in the ActiveSync programs list. However, the device will only show o the value contained in AppName, in case you were concerned about long program names showing up on your device. InstallDir is where we install our binary or any other files we may have in our cab file, again, in our case it is "Magic 8 Ball.exe" and it is installed into /Program Files.

If you do not supply a value for InstallDir the cab installer will prompt the user for a location to install your application.

[DefaultInstall]               ; operations to complete during install
CEShortcuts=Shortcuts         ; Create a shortcut
CopyFiles=Files.Common         ; Copy files, in our case "Magic 8 Ball.exe"
[SourceDisksNames]            ; directory that holds source data
1=,"Common1",,"SPEight/bin/Release/"
[SourceDisksFiles]            ; listing of all files to be included in cab
Magic 8 Ball.exe=1

DefaultInstall contains instructions for the cab installer to complete during installation on the device listed in name-value pairs. Acceptable variables are CopyFiles to perform copy operations, AddReg for registry operations, and CEShortcuts to create shortcuts to your binary from the Start Menu.

SourceDisksNames is the location on your computer of the source files where CabWizSP.exe should look to bundle into the cabinet file. Notice I created a relative link in the sample file as show above.

SourceDisksFiles is a name-value pair listing of all the files to be included in the cabinet file paired with their source directories from SourcDisksNames.

[DestinationDirs]               ; default directory destination for each
entry Files.Common=0,%InstallDir% Shortcuts=0,%CE2%/Start Menu [Files.Common] ; alias for use in DefaultInstall above Magic 8 Ball.exe,,,0 [Shortcuts] ; shortcut created in destination directory Magic 8 Ball,0,Magic 8 Ball.exe,%CE14%

Next comes a listing of the default destinations for our files and shortcuts, this is configured in DestinationDirs.

Files.Common is an example of a user-created section and Shortcuts is the shortcut created. In our case, a shortcut is created in /Windows/Start Menu/Programs/Games, meaning the navigation path to "Magic 8 Ball" would be Start -> More -> Games -> Magic 8 Ball if you install the sample cab file on your phone.

There are many ways a cab file installation might be started:

  • A link from a website, over the air (OTA)
  • An attachment in an e-mail message
  • Copy cabinet file via ActiveSync to /Storage/windows/Start Menu/Accessories, then navigate to cabinet via Start Menu on phone, Start -> More -> Accessories-> Magic 8 Ball_SMP.cab
  • Copy cabinet file to storage media and open in phone

I should mention concerning the last 2 options for installation, once the cabinet file is executed and the Cab Installer has finished it will delete the cabinet file. This is a nice feature of the installer and possibly a gotcha in the case of loading it from storage media as in the last installation option. If you want to maintain a copy of the cab, make it read only before putting it onto the Smartphone.

Wrap-up

All kidding aside, it is quite a simple matter to build a file that is ready to be distributed to Smartphone users. In the future, this process will be supported from within the Visual Studio IDE. Until that happens, you will need to tinker with .inf files and cabwizsp.exe in order to build your own installation files.

这篇关于Smartphone 2003应用程序的打包安装的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/731092

相关文章

Vite 打包目录结构自定义配置小结

《Vite打包目录结构自定义配置小结》在Vite工程开发中,默认打包后的dist目录资源常集中在asset目录下,不利于资源管理,本文基于Rollup配置原理,本文就来介绍一下通过Vite配置自定义... 目录一、实现原理二、具体配置步骤1. 基础配置文件2. 配置说明(1)js 资源分离(2)非 JS 资

RabbitMQ 延时队列插件安装与使用示例详解(基于 Delayed Message Plugin)

《RabbitMQ延时队列插件安装与使用示例详解(基于DelayedMessagePlugin)》本文详解RabbitMQ通过安装rabbitmq_delayed_message_exchan... 目录 一、什么是 RabbitMQ 延时队列? 二、安装前准备✅ RabbitMQ 环境要求 三、安装延时队

linux系统上安装JDK8全过程

《linux系统上安装JDK8全过程》文章介绍安装JDK的必要性及Linux下JDK8的安装步骤,包括卸载旧版本、下载解压、配置环境变量等,强调开发需JDK,运行可选JRE,现JDK已集成JRE... 目录为什么要安装jdk?1.查看linux系统是否有自带的jdk:2.下载jdk压缩包2.解压3.配置环境

Python库 Django 的简介、安装、用法入门教程

《Python库Django的简介、安装、用法入门教程》Django是Python最流行的Web框架之一,它帮助开发者快速、高效地构建功能强大的Web应用程序,接下来我们将从简介、安装到用法详解,... 目录一、Django 简介 二、Django 的安装教程 1. 创建虚拟环境2. 安装Django三、创

linux安装、更新、卸载anaconda实践

《linux安装、更新、卸载anaconda实践》Anaconda是基于conda的科学计算环境,集成1400+包及依赖,安装需下载脚本、接受协议、设置路径、配置环境变量,更新与卸载通过conda命令... 目录随意找一个目录下载安装脚本检查许可证协议,ENTER就可以安装完毕之后激活anaconda安装更

Jenkins的安装与简单配置过程

《Jenkins的安装与简单配置过程》本文简述Jenkins在CentOS7.3上安装流程,包括Java环境配置、RPM包安装、修改JENKINS_HOME路径及权限、启动服务、插件安装与系统管理设置... 目录www.chinasem.cnJenkins安装访问并配置JenkinsJenkins配置邮件通知

idea Maven Springboot多模块项目打包时90%的问题及解决方案

《ideaMavenSpringboot多模块项目打包时90%的问题及解决方案》:本文主要介绍ideaMavenSpringboot多模块项目打包时90%的问题及解决方案,具有很好的参考价值,... 目录1. 前言2. 问题3. 解决办法4. jar 包冲突总结1. 前言之所以写这篇文章是因为在使用Mav

Win10安装Maven与环境变量配置过程

《Win10安装Maven与环境变量配置过程》本文介绍Maven的安装与配置方法,涵盖下载、环境变量设置、本地仓库及镜像配置,指导如何在IDEA中正确配置Maven,适用于Java及其他语言项目的构建... 目录Maven 是什么?一、下载二、安装三、配置环境四、验证测试五、配置本地仓库六、配置国内镜像地址

Python安装Pandas库的两种方法

《Python安装Pandas库的两种方法》本文介绍了三种安装PythonPandas库的方法,通过cmd命令行安装并解决版本冲突,手动下载whl文件安装,更换国内镜像源加速下载,最后建议用pipli... 目录方法一:cmd命令行执行pip install pandas方法二:找到pandas下载库,然后

kkFileView启动报错:报错2003端口占用的问题及解决

《kkFileView启动报错:报错2003端口占用的问题及解决》kkFileView启动报错因office组件2003端口未关闭,解决:查杀占用端口的进程,终止Java进程,使用shutdown.s... 目录原因解决总结kkFileViewjavascript启动报错启动office组件失败,请检查of