CreateItem vs ItemGroup

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

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


    

        
4条回答
  •  自闭症患者
    2020-12-25 12:59

    In versions of MSBuild prior to 3.5 you could not define properties or items inside of targets (like in your second example). So a task was used instead (CreateItem and CreateProperty)

    If you are using ToolsVersion 3.5 then you don't need to use CreateItem anymore (though you still can if you prefer).

    In the end they both create the item the same, with the same scope. Using the second syntax is more readable and setting up custom meta data is much easier (in my opinion).

    NOTE: The 3.5 version of MSBuild is installed with .NET 3.5. Though you need to define ToolsVersion="3.5" in the Project tag of your MSBuild file to use 3.5 features.

    In case you are wondering, I got most of this info from the book Inside the Microsoft® Build Engine: Using MSBuild and Team Foundation Build which I really liked (but am not affiliated with in any way).

提交回复
热议问题