Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. function Add-LinkElement
  2. {
  3. param(
  4. [Parameter(Mandatory=$true)]
  5. [string]$csprojPath,
  6.  
  7. [Parameter(Mandatory=$true)]
  8. [string]$projectName,
  9.  
  10. [Parameter(Mandatory=$true)]
  11. [string]$outputPath
  12. )
  13.  
  14. $relativePath = "..\$projectName\"
  15. $xmlDoc = [xml](Get-Content $csprojPath)
  16.  
  17. foreach ($itemGroup in $xmlDoc.Project.ItemGroup)
  18. {
  19. foreach ($childNode in $itemGroup.ChildNodes)
  20. {
  21. if ($childNode.Name -eq "Compile" -or
  22. $childNode.Name -eq "None" -or
  23. $childNode.Name -eq "EmbeddedResource")
  24. {
  25. $link = $childNode.Include.Substring($relativePath.Length)
  26. $linkNode = $xmlDoc.CreateElement("Link", $xmlDoc.DocumentElement.NamespaceURI)
  27. $linkNode.InnerText = $link
  28.  
  29. $childNode.AppendChild($linkNode) > $null
  30. }
  31. }
  32. }
  33.  
  34. $xmlWriterSetting = [System.Xml.XmlWriterSettings]::new()
  35. $xmlWriterSetting.Indent = $true
  36. $xmlWriterSetting.IndentChars = " "
  37. $xmlWriter = [System.Xml.XmlWriter]::Create($outputPath, $xmlWriterSetting)
  38.  
  39. $xmlDoc.Save($xmlWriter)
  40. $xmlWriter.Flush()
  41. $xmlWriter.Dispose()
  42. }
  43.  
  44. Add-LinkElement -csprojPath .\src\vs-csproj\Microsoft.PowerShell.Commands.Management.csproj `
  45. -projectName Microsoft.PowerShell.Commands.Management `
  46. -outputPath C:\arena\tmp\Microsoft.PowerShell.Commands.Management.csproj
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement