Find and remove duplicate entries in csproj file

前端 未结 3 605
生来不讨喜
生来不讨喜 2021-02-10 01:07

We recently merged two branches of code and ended up with duplicate entries for several of the files in the .csproj file. This seemed to happen to all the files which needed the

3条回答
  •  滥情空心
    2021-02-10 01:24

    I used rodrigoff's .ps1 file (thanks!) but I had to modify it for my project to compile because it did not search for all entries in the csproj file, it was searching only for Compile and Content i changed this line of code:

     $entries = $xml.Project.ItemGroup.Compile + $xml.Project.ItemGroup.Content | Group-Object Include
    

    to:

     $entries = $xml.Project.ItemGroup.Compile + $xml.Project.ItemGroup.Content +$xml.Project.ItemGroup.Reference + $xml.Project.ItemGroup.EmbeddedResource + $xml.Project.ItemGroup.None + $xml.Project.ItemGroup.Page + $xml.Project.ItemGroup.Resource + $xml.Project.ItemGroup.ProjectReference + $xml.Project.ItemGroup.Folder | Group-Object Include
    

提交回复
热议问题