Creating Your First Windows 8 Application

  • 12/15/2012

Building an Executable File and Deploying

Your last task in this chapter is to complete the development process and create an application for Windows, or an executable file. Windows applications created with Visual Studio have the file name extension .exe and can be run on any system that contains Windows and the necessary support files. Visual Studio installs the support files that you need when you deploy a completed project—including the .NET Framework files—automatically.

Since you are creating an application for the Windows 8 user interface, you will need to deploy this program on a computer running Windows 8, because your application is designed for that environment. Chapter 12, “Future Development Opportunities and the Windows Store” introduces you to the Windows Store, an online purchasing and distribution system that allows Visual Studio programmers to sell their Windows 8 applications to customers around the world.

Before you prepare your app for the Windows Store, however, you need to know a little more about programming, and also a little more about how applications are compiled and tested. When Visual Studio programmers complete the initial design and functionality of their application, they typically test their program systematically to verify that the code works as expected under a variety of operating conditions. Often, more than one developer, or tester, is involved in the process, and they typically use a variety of machines, operating systems, and computing scenarios to test the seaworthiness of the application. If you examine the Build, Debug, and Test menus in the Visual Studio IDE, you’ll begin to see how elaborate this process can actually be.

To assist in the testing and compilation process, Visual Studio allows you to create two types of executable files for your Windows application project: a debug build and a release build.

Debug builds are created automatically by Visual Studio when you create and test your program. They are stored in a folder called bin\Debug within your project folder. The debug executable file contains debugging information that makes the program run slightly slower.

Release builds are optimized executable files stored in the bin\Release folder within your project. To customize the settings for your release build, you click the [ProjectName] Properties command on the Project menu, and then click the Compile tab, where you’ll see a list of compilation options that looks like the following screen. The Solution Configurations drop-down list box on the Standard Visual Studio toolbar (circled in the following image) indicates whether the executable is a debug build or a release build. If you change the Solution Configurations setting, the path in the Build Output Path text box will also change.

The process of preparing an executable file for a specific computer is called deploying the application. As noted, when you deploy an application with Visual Studio, the IDE handles the process of copying all the executable and support files that you will need to register the program with the operating system and run it. Visual Studio allows you to deploy applications locally (on the computer you are using) or remotely (on a computer attached to the network or Internet).

In the following exercise, you’ll deploy a release build for the My Web List application locally and create an application icon for the program on the Windows Start page. In Chapter 12, you’ll learn more about packaging applications that have been tested and prepared for the Windows Store.

Deploy a release build for a Windows 8 application

  1. Click the Solution Configurations drop-down list box on the Standard toolbar, and then click the Release option.

    Visual Studio will prepare your project for a release build, with the debugging information removed. The build output path is set to bin\Release\.

  2. On the Build menu, click the Deploy My Web List command.


    The Build command creates a bin\Release folder in which to store your project (if the folder doesn’t already exist) and compiles the source code in your project. The Output window appears to show you milestones in the assembly and deployment process. The result is an executable file named My Web List.exe, which Visual Studio registers with the operating system on your computer.

    Visual Studio deploys the application locally because Local Machine is currently selected on the toolbar next to the Start button. This is the desired behavior here, but you can also deploy applications on a remote machine (i.e., a computer attached to yours via a network or the Internet) by selecting the Remote Machine option. If you select this option, you’ll be presented with a dialog box asking for more information about the remote connection. Keep in mind that remote deploying is mostly designed for testing purposes. The best way to install completed applications via the Internet is through the Windows Store.

    When you deploy an application built for the Windows 8 user interface, Windows automatically creates a new program icon for the application on the Start page. You can use this icon to launch the program whenever you want to run it. Try running My Web List now from the Windows Start page on your computer.

  3. Open the Windows Start page, and browse to the list of applications that are currently installed. (The most recent applications are typically located on the right side of the Start page.)

    My Windows Start page currently looks like this:

  4. Click the My Web List application icon.

    The My Web List program will load and run in Windows.

  5. Test the application again, browsing to several web sites. When you are finished, close the application.

  6. Return to Visual Studio, and close the Output window and the My Web List properties page. Note that you can view and change compilation options whenever you want—the properties page is always there.

  7. On the File menu, click Exit to close Visual Studio and the My Web List project.

  8. Click Save if you are prompted to, and the Visual Studio development environment will close.

Congratulations on completing your first Windows 8 application!