次の方法で共有


How to: Create a Sample Project File for a Code-Only Windows Presentation Foundation Standalone Application

This example project file is for a Windows Presentation Foundation (WPF) standalone application written entirely in code-only ie no Extensible Application Markup Language (XAML). Key configuration details include:

  • OutputType. Set to winexe.

  • All C# .cs code files. Automatically compiled using a Compile element whose Include attribute is set to *.cs.

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 a standalone application automatically generated for you by using the Windows Application (WPF) project template in Microsoft Visual Studio 2005. Additionally, you'll need to remove the default generated code and XAML files: App.xaml, App.xaml.cs, Window1.xaml, and Window1.xaml.cs.

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>WPFStandaloneApplicationCodeOnly</RootNamespace>

<AssemblyName>WPFStandaloneApplicationCodeOnly</AssemblyName>

<WarningLevel>4</WarningLevel>

<OutputType>winexe</OutputType>

<ApplicationVersion>1.0.0.*</ApplicationVersion>

<BootstrapperEnabled>false</BootstrapperEnabled>

</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>

<Compile Include="*.cs" />

</ItemGroup>

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />

</Project>