Tuesday 6 November 2012

Microsoft Surface Windows 8 RT: How to deploy/debug application

Windows 8 RT has restriction on launch 3rd party application, which were downloaded/delivered to device not from Microsoft store. Microsoft selected the same strategy as Apple. I already described in previous article what will happen if you launch application, copied to the Surface device manually, even if it is compiled for the ARM processor. Operation system will show alert message:

Windows 8 RT: message "This app can't run on your PC"


The question is obvious: How to develop/deploy and test applications on your personal device?
The answer is "You have to switch you device into developer mode." I am going to describe how to do it in this article.

Development Environment:

Simple scenario (work at an office) - one PC (dev box) and Surface device on the same network segment


Technically, you need one computer with installed Visual Studio 2012 and your tablet, which is connected to the same network segment. You will use 1st one to develop application and debug application and tablet for the user interface interactions.


PC Configuration
Memory: 4Gb
CPU: i5
Operation System: Windows 8 Enterprise
Development Tool: Microsoft Visual Studio 2012
Location: Office

Microsoft Surface Device
Memory: 2Gb
CPU: ARM type
HDD: 64 Gb
Location: Office


Advanced Scenario - work remotely 

There is common scenario when your main development box (powerful one) is located at an office but you are at public place (Starbucks for example) and you need to test something and check-in code to source control system, such as TFS.  In this scenario you have to use VPN access, but it is better if you have additional laptop (any OS, which will support VPN connection and remote desktop). I am using Apple MAC Air in my case.

Here is simple diagram, which shows how it will work:



you will you use VPN connection from your laptop and Microsoft Surface to your office. You laptop will be connected to dev box by RDP (remote desktop). The result will be pretty same.

Additional laptop makes you really mobile developer and you can work from anywhere!!!!
When I am working from home, I prefer to use the same scenario but I also use Apple TV to stream my MAC Air screen to Huge TV. This is a beauty of the Apple technologies!

So....
I am using my MAc to develop applications for the Microsoft Windows 8 RT :-)

Using Apple MAC Air to RDP to MS Windows 8 Enterprise with installed Visual Studio 2012 and debug Windows 8 Rt application on my Microsoft Surface device. Screen from MAC is streamed to TV via Apple TV.



Setup Microsoft Surface device for the development

Microsoft uses the same approach as Apple - make device compatible with development mode. 
The best approach to do it is to install "Remote Tools", which come with Visual Studio 2012.


Simply copy rtools_setup_arm.exe executable file from that folder to your Surface device (ARM determines CPU. in Pro version it will be Intel) and install it. you will be prompted for couple dialog boxes and it is done.

After installation of the remote tools you will see 2 new applications at Metro-style screen: "Remote debugger" and "Microsoft Test Tools Adapter".

Windows 8 Rt with installed "Remote debugger" and "Microsoft Test Tools Adapter"

To allow Visual studio deploy/run application at Microsoft Surface device, you have to configure remote debugger. After run "Remote debugger", you have to setup security (I turned it of in this sample) and management port. If you work from multiple places, I recommend to use port 8080 - it is standard second http port for the web browsing and open in most providers, so you will not have any issues with development. 

Microsoft Remote Debugger configured at Windows 8 RT
when you will start configure remote debugging tool, you will be prompted to switch this device to development mode.



Setup Development computer

I have heterogeneous environment at my office, so i used Hyper-V to setup new instance of Microsoft Windows 8 operation system and installed Microsoft Visual Studio 2012 on it. If you interesting how it will work from learning perspective, you can download trial version of OS and dev tool, which will be valid for 90 days.

You can create any type of Metro-style project  - I used Metro-style Grid template in this sample. Next step is to configure Visual studio for the remote debugging: select project debug properties with option target device "Remote machine". You have to enter your Surface device ip address and port, which you configured in previous step.

VS 2012: setting up remote debug settings

you can also find you computer in network:

VS 2012: search Microsoft Surface with remote debugging tools

Deploy application

Next step is to prepare package and deploy it to Microsoft Surface device. you have 2 options here: manual deployment and automatic deployment during debug mode.

Setup Package Application Manifest

before create package, you have to setup some package parameters, such as application name, release version, certificate etc....
Simply find package.appmanifest file in project, double click on it and it will oped UI with configuration:




Manual deployment

If you have visual studio and don't have connected device, you can prepare package, copy it to usb key and deploy it offline. in this case, you have to do right click on properties and select "Store\Create App package" in popup menu.

VS 2012: Create application package


VS 2012: package creation - local mode



Next screen is very important for the package creation. You should setup release version, select checkbox if you want to increase release version automatically or not and you have to select compilation option for the platforms (select ARM for the Windows 8 RT).

VS 2012: package creation - release version/ compilation option  
VS 2012: package complete


After you copy package from "AppPackages" (folder can contain different releases. select which you want) to device, you have to run deployment script by right mouse click on file "Add-AppDevPackage" and select "Run with PowerShell".

Windows 8 RT: deploy package via PowerShell

Next step is magic step, which close Windows 8 RT eyes on all deployment policies and allows install application on device:

Windows 8 RT: changing the execution policy via PowerShell
After package is deployed, you should be able to see application at metro-Style style.


Automatic deployment

Automatic deployment is a beauty - you just need start Visual Studio in debug mode( press "F5" key) and application will be automatically deployed to remote device. If you did previous step, you will be alerted that such application was already deployed but you still have an option to re-deploy and run it.

Next step is to setup break points in solution and use your fingers on device touch screen.

Summary

As always, Microsoft shows that Visual Studio is very powerful tool, which allows developers to use the same tool to create/debug new types/styles of applications. I would wish if it would be the same for the rest :-)

Happy debugging!!!




3 comments:

  1. Thank u boss..

    it helped me a lot, u saved my time

    ReplyDelete
  2. Hi Denis,

    Thanks for the aricle. If i dont have PC with VS 2012 and Surface on same network , is there any alternative to copy the same (like using a memory stick etc) ?

    Thanks & regards
    GD

    ReplyDelete
  3. Interesting Article. Hoping that you will continue posting an article having a useful information. Recycle Apple Developer Enterprise Account

    ReplyDelete