Powershell Editing Xml causing Visual Studio to report Inconsistent Line Ending
Pipe Get-Content
through Out-String
:
[xml] $xml = Get-Content 'foo.xml' | Out-String$xml.foo.bar = 'baz'$xml.Save('foo.xml')
I just tested this: without Out-String
, I see the message in Visual Studio. With Out-String
, I don't, and comments are left alone.
Use the Select-Xml
cmdlet instead of the Get-Content
Use:$xml = ( Select-Xml -Path foo.xml -XPath / ).Node
Ref: https://blog.stangroome.com/2014/02/10/powershell-select-xml-versus-get-content/