How to: Create a Sample Project File for a Windows Presentation Foundation XAML Browser Application

This example project file is for a XAML browser application (XBAP), with an application definition file, App, that is configured to automatically open a page, HomePage, which is defined with XAML and code-behind. Key configuration details include:

  • OutputType. Set to winexe.

  • HostInBrowser. This is must be set to true because XAML browser applications (XBAPs) must be browser-hosted.

  • Install. This is must be set to false because XAML browser applications (XBAPs) are not installed.

  • TargetZone. This must be set to "Internet", because XAML browser applications (XBAPs) run in the Internet security zone.

  • StartAction. This must be set to "Program".

  • StartProgram. This must be set to the program that handles the process of hosting the application in the browser.

  • StartArguments. This must be set to the path to the applications manifest, which has an .xbap extension.

  • App.xaml. The application definition file being configured as an ApplicationDefinition element.

  • HomePage.xaml. A XAML file that is declared as a Page element.

  • HomePage.xaml.cs. A code-behind file that is declared as a Compile element.

  • XBAPApplication_TemporaryKey.pfx. A temporary manifest key file required by applications deployed using ClickOnce, including XBAPs.

You can reuse or modify this project file to suit your needs, as long as the files you reference are in the location you're referencing them from. Alternatively, you can have a project file for an XBAP automatically generated for you by using the XAML Browser Application (WPF) project template in Microsoft Visual Studio 2005.

This project file is for a C# project and consequently includes the Microsoft.CSharp.targets Import element. Microsoft Visual Studio 2005 gives C# project files a .csproj extension. A Microsoft Visual Basic .NET created in Microsoft Visual Studio 2005 would typically have the .vbproj extension, and would include the Microsoft.VisualBasic.targets Import element.


<Project DefaultTargets="Build" xmlns="">
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <StartArguments>-debug "$(MSBuildProjectDirectory)\bin\$(Configuration)\$(AssemblyName)$(ApplicationExtension)"</StartArguments>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <Reference Include="System" />
    <Reference Include="WindowsBase" />
    <Reference Include="PresentationCore" />
    <Reference Include="PresentationFramework" />
    <ApplicationDefinition Include="App.xaml" />
    <Page Include="HomePage.xaml" />
    <Compile Include="HomePage.xaml.cs" />
    <None Include="XBAPApplication_TemporaryKey.pfx" />
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />