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 towinexe
.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.
Example
<Project DefaultTargets="Build" xmlns="https://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<RootNamespace>XBAPApplication</RootNamespace>
<AssemblyName>XBAPApplication</AssemblyName>
<WarningLevel>4</WarningLevel>
<OutputType>winexe</OutputType>
<EnableSecurityDebugging>false</EnableSecurityDebugging>
<ApplicationVersion>1.0.0.*</ApplicationVersion>
<MapFileExtensions>False</MapFileExtensions>
<HostInBrowser>True</HostInBrowser>
<Install>False</Install>
<TargetZone>Internet</TargetZone>
<StartAction>Program</StartAction>
<StartProgram>$(WINDIR)\System32\PresentationHost.exe</StartProgram>
<ApplicationExtension>.xbap</ApplicationExtension>
<StartArguments>-debug "$(MSBuildProjectDirectory)\bin\$(Configuration)\$(AssemblyName)$(ApplicationExtension)"</StartArguments>
<SignManifests>True</SignManifests>
<BootstrapperEnabled>false</BootstrapperEnabled>
<ManifestKeyFile>XBAPApplication_TemporaryKey.pfx</ManifestKeyFile>
<ManifestCertificateThumbprint>F2E49D0E8A6FE749DE85D224F5557B875DFD5577</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>.\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
<Optimize>true</Optimize>
<OutputPath>.\bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml" />
<Page Include="HomePage.xaml" />
<Compile Include="HomePage.xaml.cs" />
</ItemGroup>
<ItemGroup>
<None Include="XBAPApplication_TemporaryKey.pfx" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />
</Project>