简体   繁体   English

为什么在任何.csproj文件中找不到<Target Name =“Build”>?

[英]Why is <Target Name=“Build”> not found in any .csproj file?

Just curious - whenever I see xml of .csproj , it starts with DefaultTargets="Build" and hence I assume that <Target Name="Build"> should be present; 只是好奇 - 每当我看到.csproj的xml时,它都以DefaultTargets="Build"开头,因此我假设<Target Name="Build">应该存在; However, I have never found this default target in any .csproj file. 但是,我从未在任何.csproj文件中找到此默认目标。

Does VS inject this target before compilation or does msbuild built it by default. VS是在编译之前注入此目标还是默认情况下msbuild构建它。 What happens internally? 内部会发生什么?

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. <Import Project="$(MSBuildToolsPath)\\Microsoft.CSharp.targets" />导入标准目标,“Build”就是其中之一。 The import generates the "Build" target in a dynamic fashion based on the other data available in the your project file. 导入基于项目文件中可用的其他数据以动态方式生成“构建”目标。

A csproj typically has this: csproj通常有这样的:

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

which according to MSDN also imports Microsoft.Common.targets which is where that target is defined. 根据MSDN,它还会导入Microsoft.Common.targets,这是定义目标的位置。

项目文件中有一个或多个<Import ...>导入应该具有该目标的其他文件...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM