Created
May 29, 2017 21:09
-
-
Save dalpert-korewireless/3f03aee829106d8cbac41460ca150664 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Task Add-CommonAssemblyInfo { | |
| dir . -Recurse -filter *.csproj | Select-Object -first 2 | % { | |
| $content = [xml](gc $_.FullName); | |
| $ns = New-Object System.Xml.XmlNamespaceManager -ArgumentList $content.NameTable | |
| $ns.AddNamespace('a', 'http://schemas.microsoft.com/developer/msbuild/2003') | |
| $assemblyInfoNode = $content.SelectNodes("//a:Compile[@Include='Properties\AssemblyInfo.cs']", $ns) | select-object -first 1; | |
| $depth = $_.FullName.Split("\").Length - 4; | |
| $commonNode = $content.CreateElement("Compile"); | |
| $commonNode.SetAttribute("Include","..\" * $depth + "CommonAssemblyInfo.cs"); | |
| $linkNode = $content.CreateElement("Link"); | |
| $linkNode.InnerText = "Properties\CommonAssemblyInfo.cs"; | |
| $commonNode.AppendChild($linkNode); | |
| $assemblyInfoNode.ParentNode.InsertAfter($commonNode, $assemblyInfoNode); | |
| $content.Save($_.FullName); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment