11

Just curious - whenever I see xml of .csproj , it starts with DefaultTargets="Build" and hence I assume that <Target Name="Build"> should be present; However, I have never found this default target in any .csproj file.

Does VS inject this target before compilation or does msbuild built it by default. What happens internally?

1
  • see the buildfiles that are imported by means of <import ...> Commented Nov 9, 2012 at 21:45

3 Answers 3

16

Near the bottom of the file you'll see this; <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> which imports the standard targets, "Build" is one of these. The import generates the "Build" target in a dynamic fashion based on the other data available in the your project file.

Sign up to request clarification or add additional context in comments.

1 Comment

How can I follow the $(MSBuildToolsPath) / $(MSBuildExtensionsPath) paths to see what the actual targets are?
6

A csproj typically has this:

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

which according to MSDN also imports Microsoft.Common.targets which is where that target is defined.

Comments

1

There is one or more < Import ...> somewhere in the project file that imports other file(s) that should have that target...

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.