How to invoke the same msbuild target twice with different parameters from within msbuild project file itself

前端 未结 3 1651
时光取名叫无心
时光取名叫无心 2020-12-28 08:04

I have the following piece of msbuild code:

  
    C:\\DirA\\
    C:\\DirB\\
           


        
3条回答
  •  Happy的楠姐
    2020-12-28 08:38

    Yes, what you want is called batching in MSBuild. The

    ;%(Dirs.Identity)
    

    Defined in the Outputs will cause this task to be executed for each item in the Dirs ItemGroup.

    
    
    
    
        
        
    
    
    
        
    
    
    
    

    Outputs:

    Build started 8/19/2009 10:11:57 PM.
    Project "D:\temp\test.proj" on node 0 (default targets).
      C:\DirA
    CopyFiles:
      C:\DirB
    Done Building Project "D:\temp\test.proj" (default targets).
    

    Change the Message task to Copy task with the following condition and you are done:

    Condition="Exists('%(Dirs.Identity)') AND '@(FilesToCopy)' != ''"
    

提交回复
热议问题