Udostępnij za pośrednictwem


MSBuild .Targets Files

Note

This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

MSBuild includes several .targets files that contain items, properties, targets, and tasks for common scenarios. These files are automatically imported into most Visual Studio project files to simplify maintenance and readability.

Projects typically import one or more .targets files to define their build process. For example a Visual C# project created by Visual Studio will import Microsoft.CSharp.targets which imports Microsoft.Common.targets. The Visual C# project itself will define the items and properties specific to that project, but the standard build rules for a Visual C# project are defined in the imported .targets files.

The $(MSBuildToolsPath) value specifies the path of these common .targets files. If the ToolsVersion is 4.0, the files are in the following location: WindowsInstallationPath\Microsoft.NET\Framework\v4.0.30319\

Note

For information about how to create your own targets, see Targets. For information about how to use the Import element to insert a project file into another project file, see Import Element (MSBuild) and How to: Use the Same Target in Multiple Project Files.

Common .Targets Files

.Targets file Description
Microsoft.Common.targets Defines the steps in the standard build process for Visual Basic and Visual C# projects.

Imported by the Microsoft.CSharp.targets and Microsoft.VisualBasic.targets files, which include the following statement: <Import Project="Microsoft.Common.targets" />
Microsoft.CSharp.targets Defines the steps in the standard build process for Visual C# projects.

Imported by Visual C# project files (.csproj), which include the following statement: <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Microsoft.VisualBasic.targets Defines the steps in the standard build process for Visual Basic projects.

Imported by Visual Basic project files (.vbproj), which include the following statement: <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />

See Also

Import Element (MSBuild)
MSBuild Reference
MSBuild