The output parameter "Copy files" of the Copy task returns all the files specified for copying, even if it does not copy anything that is specified SkipUnchangedFiles = "true",

The CopiedFiles parameter returns all files intended for copying. But given the fact that SkipUnchangedFiles is true, and ttask itself does not copy anything that can be seen on the command line (without copying the message). Why not, is CopiedFiles empty?

I need the CopiedFiles parameter to be filled only with files that were actually copied (because they were changed) in order to further copy these files to another folder. This should support the updated release folder, as well as extract only those files that should actually be transferred to the UAT / production server.

For reference, the copy task code I use is given below:

  <Copy SkipUnchangedFiles = "true"
             SourceFiles = "@ (cfile)"
                 DestinationFiles = "@ (cfile -> '$ (PublishDir) \% (Identity)')">

         <Output
                     TaskParameter = "CopiedFiles"
                     ItemName = "Changed" />

 </Copy>

 <Message Text = "changed: @ (Changed)" Importance = "high" />

Is there a mistake in the copy task or is this the expected behavior.

+4
source share
1 answer

The behavior you see is design. MSBuild tracks file dependencies using task outputs. If it had been done differently, everything that relied on an array of @ (Modified) elements as input would in most cases not have fully processed all the files it needed. It will even keep track of properties and elements created within goals that are not even executed if the inputs and outputs are updated for the same reason. Consider creating another copy task with an additional output parameter, CopiedFilesCopiedByTask (this notation reflects the naming and behavior of ValueSetByTask otherwise with the nonexistent CreateProperty task).

+3
source

All Articles