How does MSBuild check whether a target is up to date or not?

丶灬走出姿态 提交于 2019-12-04 17:53:26

问题


MSBuild emits the following message for up to date targets:

Skipping target "MyTarget" because all output files are up-to-date with respect to the input files.

How is the actual check performed?


回答1:


Check flow of Incremental Build:

A target element can have both an Inputs attribute, which indicates what items the target > expects as input, and an Outputs attribute, which indicates what items it produces as output MSBuild attempts to find a 1-to-1 mapping between the values of these attributes. If a 1-to-1 mapping exists, MSBuild compares the time stamp of every input item to the time stamp of its corresponding output item. Output files that have no 1-to-1 mapping are compared to all input files. An item is considered up-to-date if its output file is the same age or newer than its input file or files.

If all output items are up-to-date, MSBuild skips the target. This incremental build of the target can significantly improve the build speed. If only some files are up-to-date, MSBuild executes the target but skips the up-to-date items, and thereby brings all items up-to-date. This is known as a partial incremental build.




回答2:


MSBuild compares the input and output file timestamps to determine whether a file is up to date. See Incremental Builds for details.



来源:https://stackoverflow.com/questions/6982372/how-does-msbuild-check-whether-a-target-is-up-to-date-or-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!