Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Add-LinkElement
- {
- param(
- [Parameter(Mandatory=$true)]
- [string]$csprojPath,
- [Parameter(Mandatory=$true)]
- [string]$projectName,
- [Parameter(Mandatory=$true)]
- [string]$outputPath
- )
- $relativePath = "..\$projectName\"
- $xmlDoc = [xml](Get-Content $csprojPath)
- foreach ($itemGroup in $xmlDoc.Project.ItemGroup)
- {
- foreach ($childNode in $itemGroup.ChildNodes)
- {
- if ($childNode.Name -eq "Compile" -or
- $childNode.Name -eq "None" -or
- $childNode.Name -eq "EmbeddedResource")
- {
- $link = $childNode.Include.Substring($relativePath.Length)
- $linkNode = $xmlDoc.CreateElement("Link", $xmlDoc.DocumentElement.NamespaceURI)
- $linkNode.InnerText = $link
- $childNode.AppendChild($linkNode) > $null
- }
- }
- }
- $xmlWriterSetting = [System.Xml.XmlWriterSettings]::new()
- $xmlWriterSetting.Indent = $true
- $xmlWriterSetting.IndentChars = " "
- $xmlWriter = [System.Xml.XmlWriter]::Create($outputPath, $xmlWriterSetting)
- $xmlDoc.Save($xmlWriter)
- $xmlWriter.Flush()
- $xmlWriter.Dispose()
- }
- Add-LinkElement -csprojPath .\src\vs-csproj\Microsoft.PowerShell.Commands.Management.csproj `
- -projectName Microsoft.PowerShell.Commands.Management `
- -outputPath C:\arena\tmp\Microsoft.PowerShell.Commands.Management.csproj
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement