CreateItem vs ItemGroup

前端 未结 4 1754
轻奢々
轻奢々 2020-12-25 12:10

What is the difference between creating an item inside a target like this:


    

        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-25 12:50

    CreateItem and CreateProperty are obsoleted in MSBuild 3.5 (though will always continue to work, of course). It was pretty obvious we needed the same familiar syntax for ItemGroup and PropertyGroup to work inside targets.

    But ItemGroup inside a target has some special extra powers. It can modify items: for example, this will add true to all items in Resources list that have a metadata named Primary with value of true; only if there isn't already Copy metadata:

    
      
        true
      
    
    

    One other magic power: you can now remove items from a list. This example will remove all items from the Resources list that have metadata Type with value Bitmap:

    
      
    
    

    These magic powers only work inside at present, not outside.

    For full details of this stuff, I highly recommend Sayed Hashimi's book on MSBuild. It's easily found on Amazon.

    Dan -- msbuild team.

提交回复
热议问题