Loading user information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading user information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Part 8: Understanding Compilation and Deployment

14 minutes, 49 seconds


Right click “Save as…”

Source Code: http://aka.ms/absbeginnerdevwp8
PDF Version: http://aka.ms/absbeginnerdevwp8pdf

If you'll recall from the C# Fundamentals series, the C# compiler compiles the code in your project to create a .NET Assembly. The end result is usually (at least, in the case of simple Console applications) an executable file with the file extension ".exe". While we worked exclusively with the debug version of the app in Visual Studio, by changing the Solution Configuration to Release we could create a version of the application suitable for deployment on another user's computer ... as long as they had the same version of the .NET Framework Runtime installed on that computer.

In this lesson, I want to talk about deploying the app we build to a physical device running the Windows Phone 8 Operating System. Up until now, we've merely deployed to the Phone Emulator. The compilation and deployment step is automated for us, and we may not be aware of how the program is packaged and installed into the Emulator. Furthermore, we will want to understand the way in which the app is packaged because we'll want to undoubtedly deploy the app to a physical phone device for testing, and we'll want to package the app so that we can submit it to the Windows Store to be approved and included there for download or sale.

So our game plan in this lesson:

  1. I want us to see what happens when we compile our app ... what does Visual Studio create? Maybe we can learn a little about the deployment process as a result.
  2. I want to deploy to an actual physical phone device, just to see our PetSounds app running on a real phone

1. Discovering what happens during compilation and deployment

Each time we run the app by hitting F5 on our keyboard, or the Run button on the toolbar, Visual Studio is creating a Debug version of our app. If you'll recall from the C# Fundamentals series, it creates a Bin\Debug directory where it places the .NET assembly as well as any additional files required for the app to run. Here's what the Bin\Debug directory looks like for our PetSounds app:

We see the .NET assembly (PetSounds.dll) and a file that we can ignore that helps coordinate Visual Studio's debugger with the running version of the app (PetSounds.pdb). There's some folders that match ones in our Visual Studio project, like the Assets folder, the es folder for the Espanol version of our AppResources.resx, and a Properties folder. Then there's a AppManifest file and a PetSounds_Debug_AnyCPU.xap.

The .xap file is quite large (6 MB). I happen to know that file extension indicates that it is the deployment package ... a file containing all the files and configurations required to deploy our app on the Windows Phone 8 OS.

Let's have a little fun. I'm going to copy that file to my Desktop ... I right-click the file, select Copy ...



... I right-click my Desktop and select Paste.

Once the file is on my Desktop, I right-click it and select Rename ...



... and I change the file EXTENSION from .xap to .zip ... Windows warns me that this might harm the file:



... this is only a copy, and Visual Studio creates a new .xap each time we deploy, so I select the Yes option in the dialog.

The file now looks like any other .zip file on my computer.



If I select the file in Windows Explorer, I can see its contents (even if I don't choose to Extract the files):



Wow, the .xap file is actually a fancy .zip file containing (essentially) what we saw in the \Bin\Debug directory of our Project! Drilling into the /Assets sub-directory ...



... and eventually into the /Audio and /Animals folder structure, I see the .wav files that we copied into the project a few lessons ago in there.

Let's back out to the root of that .zip file ... I want to see what's inside the AppManifest.xaml and WMAppManifest.xml files ... I right-click on the WMAppManifest.xml file ...



You may be asked which application in Windows 8 you want to use to open this file. Choose Notepad.



In Notepad you can see the true nature of the WMAppManifest.xml file ... it's simply XML ... just a lot of it. In Visual Studio, this complexity is hidden from us through a friendly "designer" ... a page in Visual Studio that restricts the changes we can make to the file.



The real question is: "why does it exist?"

The purpose of the WMAppManifest.xml is to introduce your app to the Phone. It tells the Phone which images to use as Tiles on the Start and Application pages. It tells the Phone which capabilities we hope to use and which languages we can support. It tells the Phone what our name is, and which version of the app this is, which screen resolutions we support, and so on. It is how we integrate our app into the Windows Phone 8 Operating System and ecosystem of apps.


3. Deploying to a physical phone

The final thing I want to try in this lesson is to deploy the app to my Lumia 920 phone. The rest of this lesson assumes you already have a Windows Phone Dev Center membership. It costs $99 per year.

First, I plug my phone into my computer using the USB cord that comes with the phone. I've done this many times before to transfer my music or charge the phone, but never with the intent of deploying an app to it.

In Visual Studio, I'll change from debugging in the Emulator to debugging on the Device using the little down-arrow next to the Run button to choose that option:



Next, I'll click the Run button on the toolbar, but will get an error:



So, the first thing I need to do is to unlock the phone for development. The URL in that message doesn't work ... use this URL instead to learn more:


I'll search for the Windows Phone Developer Registration app that was installed when I installed the Windows Phone 8 API on my computer.

In Windows 8, go to the Search charm ...



... and type in "Regi" ...



... that should be enough to locate the Windows Phone Developer Registration app ...



Start the app. It will take you back to the Desktop and display the following dialog ... as you can see, it tried to determine the status of my phone, however the lock screen was locked.



I unlock the lock screen and click the Retry button.



I click The Register button button and it asks me to Sign In to my Microsoft account ...



... Just a note, this always require I sign in twice for some reason. Don't be alarmed if you experience a similar behavior. You can usually get in on the second try.

After a moment, I get a confirmation that the phone was successfully unlocked for development:



I can confirm this by logging into:



(1 ) I navigate to the Dashboard
(2 ) Account
(3 ) Phones
(4 ) The phone I just registered shows up there correctly.

You'll note the name of the phone ... "Bob Tabor's Phone" ... I changed that in Windows Explorer by right-clicking the phone and selecting "Rename". This will allow me to test on multiple phones and tell them apart.

Now that I have the phone registered, I should be able to deploy the app to the Device.



But alas ...



... I must unlock the Device's lock screen and try again.

But after I overcome all the obstacles, I can finally see my PetSounds app running on my phone ...



... and not only can I see it, but it actually works! I can annoy my kids and pets with a duck quack!

To exit out of the debug session, use the Stop button on Visual Studio's toolbar just like you would if you were running in the Emulator.



Even though I stop debugging the app on my Device, the app is still present there and I can still run it even if I unplug the Device from the computer. Each time I debug, it will deploy the latest version of my app to the physical device just like it did in the Emulator.

Before we move on, you may see a message like this in the future:



Apparently, there's a limit to the number of apps you can deploy to the phone. I think it is limited to 10. If that happens, just uninstall one or more developer apps the way you would uninstall a regular app. I.e., hold down on the tile and select Uninstall.

And suppose that you want to unregister your phone for development for some reason. You can re-run the Windows Phone Developer Registration Tool and it will identify the phone as being unlocked for development and provide an option to Unregister the phone:



4. Obtaining a Windows Phone Dev Center membership

Finally, as I alluded to earlier, before you can register a phone for development and deploy your apps to it for testing, or later sell your apps in the Marketplace, you'll need a Windows Phone Dev Center membership. It costs $99 per year if you purchase it directly from Microsoft.

However, there is a second option. Nokia has a Premium Developer Program for Lumia that not only gives you a Windows Phone Dev Center membership, but also gives you Telerik's Rad Controls for Windows Phone, a Buddy.com membership and two Nokia tech support tickets that you can use, presumably, if you run into challenges while developing or deploying you Phone apps. This is the deal I took advantage of and it worked swimmingly.




To recap, the big take away in this app was the composition of a deployment package, the purpose of the WMAppManifest.xml file, and deploying to a physical phone device for debugging from Visual Studio. We talked about registering your physical device to unlock it to deploy developer apps to it, and how to obtain a Windows Phone Dev Center account.


Follow the discussion

  • Oops, something didn't work.

    Getting subscription
    Subscribe to this conversation
  • Jaime TibaduizaJaime Tibaduiza

    If we wanted to deploy an app internally within Microsoft, before submitting to the store, is there such possibility. As I see this, it seems that we could only do it through the store. Is this correct?

  • @jaime tibaduiza : i guess you can do it with windows intune

  • @Jaime Tibaduiza: Here's what you need to know:


  • Will you please explain me how to deploy the WP8 apps created by me in MS VS Express 2012 to HTC 8s phone. I want to deploy the apps only for testing. I tried to do this in two ways:

    1. I connected my phone to the PC by USB cable, unblocked the screen and rebuild the app in VS for Device not for Emulator. The first rebuild was OK but I could not find the app on the phone - where to look for the application on the phone?

    When I tried to rebuild the same app in VS for second, third ... times - I got the error: Error 1 Error writing file '%FOLDERID_SharedData%\PhoneTools\11.0\Install\{19310bdd-ad30-4529-bf8b-ff470876c8d6}\PhoneNotes.xap'. Error 0x80070003: System cannot find the path - what is the reason of the error?

    My notebook does not support SLAT, so my MS VS Express 2012 does not have emulators for WP8 - could it be the reason of failure?

    2. I tried to use Application Deployment utility - I connected the phone, unlocked the screen, started Application Deployment, selected my XAP file and pressed Deploy button. I always received error 0x8973190E without any additional comments. They say it means the lack of storage, but my phone is empty, it is quite new.Could I use the Application Deployment for copying the apps to the phone?

    I have a developer account and my HTC 8S is registered, but my account is not payment - could it be the reason of failure?

    I ask this questions for many days in several Russian and English forums and nobody answered. Does it mean that the questions are not worth answering because they are easy? Or they are too difficult to answer? How do you people develop the applications for Windows Phone 8?

  • Clint RutkasClint I'm a "developer"

    @Gag63: when you set the target to "Device" and hit the play button (F5 will also deploy with debugger) does the application launch on your phone?

  • Clint RutkasClint I'm a "developer"

    @Gag63: also do you have spare space on your device?  those devices are pretty slim on memory.

  • @Clint:No application does not launch on the phone and I cannot find them on the phone either. What about the memory - my phone is "empty". I did not loaded any music, or video or anything else. Clint, could you please explain me the situation with my account. I haven't pay $99 so far and registered a free account. In my account summary the option 'Payment account' has value "No payment account'. But my phone is there. So could this be the reason of my deployment failure?

  • Clint RutkasClint I'm a "developer"

    @Gag63: The fact if you hit F5 and the application doesn't deploy to the phone, it won't actually show up.  Basically the app isn't getting deployed.

    • Can you create a brand new application on your desktop or try to deploy one of our applications from the lessons from where the folder lives on your desktop?  The error you listed is what is making me think this.  That file path is just odd.
    • Are you 100% you dev unlocked your phone?  (developer register)  Just like the steps above in this lesson.
  • @Clint: Thank you for the hint! I created a new app from the very beginning, tried to deploy it and it worked! The applications I tried to deploy before were initially created under Windows 7, then I copied them to the notebook with Window 8, rebuild them and tried to deploy. I will just create them again from the beginning in Windows 8. Thank you once again!

  • Clint RutkasClint I'm a "developer"

    @Gag63: bet windows went into protect mode and blocked a DLL or something to that regard

  • Clint RutkasClint I'm a "developer"

    @Gag63: doing a "Clean Solution" and then rebuilding typically fixes that issue if it is something in the bin directory causing the problem.

  • Erick GErick G

    Bob i´m having a trouble deploying the app to the phone, it ses that the port is al ready in use for other aplication ¿?¿ what might be the problem

  • @Erick G: Could be that when you plugged the phone into the computer via USB, the "Windows Phone app for desktop" (http://www.windowsphone.com/en-us/how-to/wp8/windows-phone-app-for-desktop) might be launching.  You may need to close (really close, not just minimize) that app before proceeding.

  • Clint RutkasClint I'm a "developer"

    @Erick G: Weird, I'm wondering does your user name have a non-latin character in it?  Looking at http://social.msdn.microsoft.com/Forums/wpapps/en-US/2ce4f920-8561-4bb9-9ee7-6cd7cb27a51e/wp8-sdk-app-deployment-to-emulator-does-not-work?forum=wptools a user reported that it caused him an issue.  http://superuser.com/questions/495290/how-to-rename-user-folder-in-windows-8 fixed it for them.

  • Clint RutkasClint I'm a "developer"

    @Erick G: I actually just hit this!  I have multiple instances of VS 2013 and VS 2012 open and they are trying to talk to the same emulator instance.  Shutting down and restarting the emulator fixed it for me.

  • @BobTabor:

    As per the registration process mentioned for Windows Phone 8

    I have ensured below things :-

    a. Unlocked the phone screen.

    b. On my phone, I ensured that the date and time are correct.

    c. Connected my phone to computer by using the USB cable.

    d. Under Windows Phone SDK 8.0, I clicked Windows Phone Developer Registration.

    e. But after clicking Register button, it gives blank Sign in Page

    Please tell us the solution.

    Please tell if this is OS issue, mobile issue or some other issue

    P.S. 1. The phone is not having sim card and hence not connected to internet. However it is connected to the PC which is internet enabled.

     2. We had installed WP8 10322 Emulators.exe but that too didn't solve the problem

    Thanks in advance.
  • Clint RutkasClint I'm a "developer"

    @sarddsp: your computer must be connected to the internet as it must authenticate.

  • @Client Thanks. It was internet proxy issue. It was blocking Microsoft locking log in site.

    It worked with different proxy

  • @BobTabor:I deployed a simple app to my lumia 820 ,just like PetSounds,that when i hit the botton there would be a piece of music playing .But i found that every time i switched to the start page and came back immediately ,it didn`t work normally... the music was gone no matter how i click the botton!Could you please tell me what the problem might be?

  • Clint RutkasClint I'm a "developer"

    @fengzili: confused what you mean by hitting the bottom.  Does our sample app work?

    one big thing to remember is we are building out the application more and more each lesson.  Could be a certain feature isn't added in yet

  • @Clint:forgive my poor english.I got the "button" and "botton" mixed up. Blushing

    i really hope that the app would not stop the sound when i turn to another app,but the fact is it stoped the sound automatically.

  • Clint RutkasClint I'm a "developer"

    @fengzili: it is possible but requires far more work than our series covers.  Look at a background audio agent

  • Hi Bob,

    I need help. I did everything as you said till lesson#8, but in the bin/debug/release/assets file there was no audio file. And my .xap file was only 44kbs in size. I checked in the solution explorer and the audio file was there. I downloaded the source code from your website but there was no assets file in the bin/debug/release directory.
    I tried again, and started from lesson#3, but the problem still persists. Please help. please.
    This is the build log:
    1>------ Build started: Project: PetSounds, Configuration: Debug Any CPU ------
    1>  PetSounds -> C:\Users\Karthik\AppData\Local\Temporary Projects\PetSounds\Bin\Debug\PetSounds.dll
    1>  Begin application manifest generation
    1>  Application manifest generation completed successfully
    1>  Begin Xap packaging
    1>  Creating file PetSounds_Debug_AnyCPU.xap
    1>  Adding PetSounds.dll
    1>  Adding Assets\AlignmentGrid.png
    1>  Adding Assets\Tiles\FlipCycleTileLarge.png
    1>  Adding Assets\Tiles\FlipCycleTileSmall.png
    1>  Adding Assets\Tiles\IconicTileMediumLarge.png
    1>  Adding Assets\Tiles\IconicTileSmall.png
    1>  Adding AppManifest.xaml
    1>  Adding Assets\ApplicationIcon.png
    1>  Adding Assets\Tiles\FlipCycleTileMedium.png
    1>  Adding WMAppManifest.xml
    1>  Xap packaging completed successfully
    ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

  • Clint RutkasClint I'm a "developer"

    @ktl94: looking at that output, you didn't include the sound files in your project. 

  • @Clint: Precisely, I don't know why this happens. When I drag and drop I see this brief window where it tells me it's adding the audio file. But it doesn't show up in the build log. And the .xap file remains 44 kbs. What to do? I can't proceed without this.

  • Clint RutkasClint I'm a "developer"

    @ktl94: in VS in the solution explorer, do you see any of the sound files in the project?


  • Yes I do see it. It is visible in the solution explorer. But doesn't show up in the build log, and .xap file remains 44 kbs.



  • Clint RutkasClint I'm a "developer"

    @ktl94: when you highlight a sound, what are they listed as?  Can you just upload the project at https://absolutebeginner.codeplex.com/WorkItem/Create so I can take a look?

  • @Clint: Nothing happens when I hover my mouse over any particular sound on the solution explorer window. I tried uploading the app in the link you gave me, but I couldn't upload the whole project as there was 4mb limit, and my whole project is about 8mb. So I just uploaded the .xap file. Hope that helps. I am extremely sorry if I uploaded some wrong file/folder.

    Thanks a ton.

  • Clint RutkasClint I'm a "developer"

    @ktl94: I need the project, I to see a few things.  Delete the bin, obj and the audio from the physical folder then zip and I can do the rest.  I want to see what is going on.

    are you trying to drag the audio from a zip file into VS or are the files fully extracted out?  If it is from the zip, that could be the issue right there.

  • @Clint:Ok Sir I deleted the bin, obj, and the audio file (from the first assets folder).
    And then zipped it.

    The first time I tried to drag and drop the audio from a zipped folder, it didn't permit me. The file didn't even go to the solution explorer. I had to unzip it for it to appear in the solution explorer, which I did the second time.

    But when I restarted building the app, I had done the first dragging and dropping from a unzipped folder itself.

    Please help. Thanks a ton.

  • Clint RutkasClint I'm a "developer"

    @ktl94: filed played just fine for me and copied over.  not sure what is the differences between my system and your system.  There has to be a big difference.  I'm running a stock Win8.1 system with on bare metal (not running through a VM) with full admin priv.

  • Clint RutkasClint I'm a "developer"

    @ktl94: my XAP is 6mb post compile

  • @Clint: Well dunno. Still the same prob. Anyway continuing on with lesson#10.


  • Hi Bob.

    This is a great series, thank you. 

    I have a question though. Can I deploy app on my phone and use it with out creating developer ID? Thing is I learn programming because I need some tools on my phone which make sense only to me and I don't plan to distribute it. I don't want to pay 99 dollars for app which will  never get to market. Is there any workaround?

  • @nighilanth: Great question. I *think* you can deploy to your own phone without a dev id.  I've forgotten the sequence of steps -- at what point does the dev id become required -- but I'm pretty sure you can.  Create a hello world app and try it ... wouldn't take more than 5 minutes to find out for sure ... then let us know!!!  Smiley

  • @BobTabor: I was able to debug-run app on my phone without registering for developer account. I just provided my Live ID and it worked.

  • @nighilanth: Ah, very cool.  Thanks for reporting back!

  • HashHash

    How can we deploy the xap file from my windows 7 operating system PC to windows 8 mobile phone. Please reply... Thanks in advance...

  • Abdul RahmanAbdul Rahman

    I am from Afghanistan, I have developed my 1st wp8 app and I would like to use Nokia Premium Developer account, It seems i cannot use this account as this is not available for my country. Is there alternate to this?


    fantastic series bob,,,
    but there is this really annoying problem i am facing,
    i cant get hyper-v or s.v.t anywhere in bios!!

    i am using hp envy-1102tx
    2 gb amd graphics
    win 8 64 bit

    please help me out!!!

    where as i had my old laptop dell,this worked fine!!!

    thanks in advance

  • Neil TNeil T

    A great series so far.. Thanks.
    Just one small thing though, I deployed the app to my Nokia 1020 and works but if the volume isn't cranked up to 30/30 it is barely auditable. Is there a reason for this?

    Thanks Again.

  • Ruben SvarteRuben Svarte

    I've been a C# developer for many years and these videos made me want to start writing Windows Phone apps. So I bought a Nokia Lumia 1020 and connected it to my Windows 8.1 computer. But no show! Actually no USB devices are detected by Windows. Any ideas?

  • Ruben SvarteRuben Svarte

    I found a work-around. If I connect my phone via USB nothing happens, but when I restart Windows the device is found. Hope this helps others with the same problem.

  • @Ruben Svarte: I had a similar issue.  However, I downloaded the Windows Phone app from the Windows app store and I was able to connect.

  • ChuckJChuckJ

    You mention how large the xap can get with these files. How much modification would be need to use a direct url of the mp3 file? My app is getting to nearly 60 mb. Id love to be able to not store the audio files and use a url instead. Ive got a place I can use to directly get the mp3 file, but when I try to use a url as a source, it does not work.

Remove this comment

Remove this thread


Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.