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>


[535 byte] By [KeithHill] at [2007-12-17]
# 1
I see that GenerateResource does it owns timestamp checking and the help topic even mentions that you shouldn't use Target's Inputs and Outputs attributes. How does a task participate in TLDA (or target skipping) like this? Is this something that custom tasks can do? Or is it an "internal" only feature?
KeithHill at 2007-9-9 > top of Msdn Tech,Visual Studio,Visual Studio MSBuild...
# 2
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

RajeevGoelmsft at 2007-9-9 > top of Msdn Tech,Visual Studio,Visual Studio MSBuild...
# 3
So how does a task report to MSBuild that a target can be skipped? Is that something we have access to?
KeithHill at 2007-9-9 > top of Msdn Tech,Visual Studio,Visual Studio MSBuild...
# 4
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

RajeevGoelmsft at 2007-9-9 > top of Msdn Tech,Visual Studio,Visual Studio MSBuild...
# 5
Doh! I see. The GenerateResource target is spitting out a message saying that it is skipping resource generation. I mistook that for the normal "Skipping target ..." message. Serves me right for working on this so late in the evening.
KeithHill at 2007-9-9 > top of Msdn Tech,Visual Studio,Visual Studio MSBuild...

Visual Studio

Site Classified