By default, when Visual Studio executes a smart device test run, it copies the test assemblies and all its dependent assemblies down to the device. However, there may be scenarios where you would want to deploy other files like some xml files or .sdf database files on which the tests depend.

In this blog, I will describe a few ways in which you can achieve deployment of files as part of the Smart Device Test Run. You can use any of the methods based on the scope of the deployment items.

Deployment using the Run Configuration

This method sets the deployment items for the run configuration. You can specify the files and folder to be deployed in the Deployments Page after opening the run configuration in the Run Configuration Editor.

 At the start of the run, all the deployment items (files and folders) specified in the active run configuration will be copied over to the device. These items will be copied over to the Test Deployment Folder on the device (i.e. \Program Files\SmartDeviceTest\<TestRunFolder>\Out ). The default format for the Test Run Folder name is <user name>@<computer name> <date> <time>, and can be configured using the Test Run naming scheme in the Run Configuration File.

Deployment Attribute

The deployment attribute can be used to specify deployment items such as files or directories for per-test deployment. This attribute can be specified on a test method or on a test class and there can be multiple instances of this attribute to specify more than one item. Examples:

[DeploymentItem(@"D:\My.txt")] // copies my.txt to the test deployment directory

[DeploymentItem(@"D:\My.txt", "DataFiles")] // copies my.txt to a DataFiles subdirectory under the test deployment directory


Note: In case there is a collision between filenames specified in the runconfiguration and the per-test deployment items, the runconfiguration takes higher precedence, i.e. the file specified in the test runconfig will be deployed.  


Setup script

The above two mechanisms allow deployment of items only under the test deployment directory. In case your tests require some files to be copied to the device outside the test folder, like in windows folder, you can use this method. However this method is not so straight and requires more work.

The run configuration allows specifying a setup script (.bat/.cmd file) that is executed at the start of the run.  What you can do is write a utility application using the core-con managed API to copy the files from the desktop to the device and then invoke this utility from the setup script.

To simplify this process, I have compiled a tool “RemoteDeploy” that will do what I mentioned above. You can download this tool and then author a batch script that invokes this tool as below. Set this batch file as the setup script in the run configuration.


start remotedeploy.exe  /platform:"Pocket PC 2003" /device:"Pocket PC 2003 SE Emulator" /source:”d:\myfile.txt” /dest:”Windows”

At the start of the test run, the set up script will be executed which will connect to the PPC 2003 SE Emulator and will deploy myfile.txt to the Windows folder on the device. If there is a collision between files deployed by the setup script and by the run configuration, the run configuration will take higher precedence.

Note: The remote deploy tool requires a platform and device switch. This must match the device specified in the smart device run configuration. Any change made to the platform or device in the run configuration will need to be manually reflected in the setup script.

The RemoteDeploy application can do more than just copying files. You can also deploy NETCF (2.0 / 3.5) , SQLCE and other CoreCon packages onto the device using this tool. For more help on the tool use it with the /help switch.

e.g. The below command will deploy NETCF 3.5 on the PPC 2003 SE Emulator.

remotedeploy.exe /platform:"Pocket PC 2003" /device:"Pocket PC 2003 SE Emulator" /package:NetCF3.5  

Since Unit Test execution in Orcas currently does not install NETCF / SQLCE, you can use this tool in the setup script to automate installation of NETCF / SQLCE or any other package, which your tests depend on, before the start of the run.