Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is what we went with: </p> <pre><code>&lt;UsingTask TaskName="CompareDates" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" &gt; &lt;ParameterGroup&gt; &lt;FileList ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" /&gt; &lt;CacheFile ParameterType="System.String" Required="true" /&gt; &lt;Result ParameterType="Microsoft.Build.Framework.ITaskItem[]" Output="true" /&gt; &lt;/ParameterGroup&gt; &lt;Task&gt; &lt;Using Namespace="System"/&gt; &lt;Code Type="Fragment" Language="cs"&gt; &lt;![CDATA[ var modifiedFiles = new List&lt;ITaskItem&gt;(); //If the cache file exists, only return files that have been edited more recently than it if(File.Exists(CacheFile)) { DateTime cacheTimeStamp = File.GetLastWriteTime(CacheFile); foreach(var file in FileList) { if(DateTime.Compare(DateTime.Parse(file.GetMetadata("ModifiedTime")), cacheTimeStamp) &gt; 0) { modifiedFiles.Add(file); } } Result = modifiedFiles.ToArray(); } //Otherwise, return all files else { Result = FileList; } ]]&gt; &lt;/Code&gt; &lt;/Task&gt; &lt;/UsingTask&gt; </code></pre> <p>We used it as follows:</p> <pre><code>&lt;CompareDates FileList="@(Compile)" CacheFile="My.StyleCop.Cache"&gt; &lt;Output TaskParameter="Result" ItemName="ChangedFiles"/&gt; &lt;/CompareDates&gt; </code></pre> <p>And updated the cache (after the stylecop task is executed):</p> <pre><code>&lt;Touch Files="My.StyleCop.cache" AlwaysCreate="true" Condition="'$(StyleCopViolationCount)' == '0'"/&gt; &lt;CreateItem Include="Apt.StyleCop.cache"&gt;`enter code here` &lt;Output TaskParameter="Include" ItemName="FileWrites"/&gt; &lt;/CreateItem&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload