Advertisement
Guest User

Untitled

a guest
May 21st, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. <#
  2. .SYNOPSIS
  3. Find-CsprojDuplicatedIncludes
  4. .DESCRIPTION
  5. This function finds all duplicated content include markups in .csproj file.
  6. It might be useful after merging two branches in TFS or other source control
  7. system. If you merge without caution it might cause some mess in your .csproj
  8. file.
  9. .EXAMPLE
  10. finddup .\tfs\EnterpriseProj\EnterpriseProj.Web\EnterpriseProj.Web.csproj
  11. .NOTES
  12. author: Albert
  13. #>
  14. function Find-CsprojDuplicatedIncludes {
  15. [cmdletbinding()]
  16. Param(
  17. [Alias('FilePath', 'Path')]
  18. [string] $csprojFilePath = $vsFullPath
  19. )
  20.  
  21. $duplicateHash = @{}
  22. Get-content $csprojFilePath | `
  23. Where-Object { $_ -match "<Content Include=`".*`"( /)?>" } | `
  24. ForEach-Object {
  25. $_ = $_.Trim()
  26. if($duplicateHash[$_]) {
  27. $duplicateHash[$_] = $duplicateHash[$_] + 1
  28. }
  29. else {
  30. $duplicateHash[$_] = 1
  31. }
  32. }
  33.  
  34. $duplicateHash.GetEnumerator() | `
  35. Where-Object { $_.Value -gt 1 } | `
  36. ForEach-Object { $_.Name }
  37. }
  38.  
  39. New-Alias -Name Find-CsprojDup -Value Find-CsprojDuplicatedIncludes
  40. New-Alias -Name finddup -Value Find-CsprojDuplicatedIncludes
  41. Export-ModuleMember -Alias * -Function Find-CsprojDuplicatedIncludes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement