From 04b41c03c5940b877920eb7f6195000f5dd212df Mon Sep 17 00:00:00 2001 From: TeBeCo Date: Fri, 3 Nov 2017 22:12:39 +0100 Subject: [PATCH] use XmlWritter to avoid serialising Xml Declaration in csproj --- ElectronNET.CLI/Commands/InitCommand.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ElectronNET.CLI/Commands/InitCommand.cs b/ElectronNET.CLI/Commands/InitCommand.cs index 592d608..b78bef6 100644 --- a/ElectronNET.CLI/Commands/InitCommand.cs +++ b/ElectronNET.CLI/Commands/InitCommand.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; +using System.Xml; using System.Xml.Linq; namespace ElectronNET.CLI.Commands @@ -147,10 +148,19 @@ namespace ElectronNET.CLI.Commands stream.SetLength(0); stream.Position = 0; - xmlDocument.Save(stream); + var xws = new XmlWriterSettings + { + OmitXmlDeclaration = true, + Indent = true + }; + using (XmlWriter xw = XmlWriter.Create(stream, xws)) + { + xmlDocument.Save(xw); + } - Console.WriteLine($"{ConfigName} added in csproj!"); } + + Console.WriteLine($"{ConfigName} added in csproj!"); return true; } }