TLDA and Inputs/Outputs
How come the following target seems to do TLDA without me specifying Inputs and Outputs for the Target?
| |
<Target Name="GenResources"> <GenerateResource Sources="@(Resource)" OutputResources="@(Resource->'%(filename).resources')"/> </Target>
|
In this case, the implementation of the GenerateResource task does the timestamp checking, and skips the work if everything is already up-to-date. This logic had to be pushed down to the task implementation because .RESX files can essentially #include other files. So, in order to check timestamps correctly, we have to know the complete set of input files, and the only way to know that is to crack open the .RESX files, which only the task knows how to do.
--Rajeev
Sorry, I wasn't clear. There is no special contract here between the task and MSBuild. What is happening is that because of the lack of an "Inputs" and "Outputs" attribute on the <Target> element, MSBuild is going to always execute the tasks within that target. Beyond that, it is completely up to the implementation of the task to do whatever it wants.
So, the GenerateResource task does its own timestamp checking, and if it decides that everything is up-to-date, it simply returns "true" from the Execute() method without actually doing any real work. As far as MSBuild is concerned, the target and task were executed successfully, even though no real work was performed.
--Rajeev