How can I do custom execution of an MSBuild job based on file timestamp?

The C ++ project I'm working on (which I converted from VS2008 to VS2010) used several vcbuild.rules files to specify custom build rules. These .rules files had a specific “AdditionalDependencies” property for the CustomBuildRule node, which lists the files that should be taken into account when developing if the target needs to be rebuilt or not. These "AdditionalDependencies" were reliably transferred to the corresponding .props file during the VS2010 conversion.

The .targets file associated with the custom string rule adds these AdditionalDependenciesto the Inputs Targetnode property . This ensures that the goal will be met if any of the files listed in the dependencies does not exist, but does not fulfill the goal if one of the dependencies is newer than the target result. This is also not entirely logical, since not all files are actually inputs, some of them relate to executable files that can be used during the assembly of the target. Thus, they can be checked in version control and will be present, but a newer version of the file should initiate the reconstruction of the affected target.

The MSDN documentation for the Target node shows a property Conditionthat should work fine for my requirements, but the conditions supported by this property do not appear after the Exists test, which is already running.

Is there some condition that I can use that will compare the timestamps of the two files (or, ideally, the timestamp of the files that are currently specified in the AdditionalDependenciesoutput files of Target), and thus let me run make- like "restore this goal, if it is out of date, these dependencies"?

+5
source share
1 answer

Note the target property Output:

"MSBuild , , . , - @(CSFile) , hello.exe, MSBuild , :"

<Target Name="Build" 
    Inputs="@(CSFile)" 
    Outputs="hello.exe">

    <Csc
        Sources="@(CSFile)" 
        OutputAssembly="hello.exe"/>
</Target>

MSBuild .

+2

All Articles