Skip to content

Commit 93b7c94

Browse files
Merge pull request #32 from tebeco/no_xml_declaration_in_csprojet
use XmlWritter to avoid serialising Xml Declaration in csproj
2 parents 0b351bb + 04b41c0 commit 93b7c94

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

ElectronNET.CLI/Commands/InitCommand.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Runtime.InteropServices;
66
using System.Text;
77
using System.Threading.Tasks;
8+
using System.Xml;
89
using System.Xml.Linq;
910

1011
namespace ElectronNET.CLI.Commands
@@ -147,10 +148,19 @@ private static bool EditCsProj(string projectFile)
147148
stream.SetLength(0);
148149
stream.Position = 0;
149150

150-
xmlDocument.Save(stream);
151+
var xws = new XmlWriterSettings
152+
{
153+
OmitXmlDeclaration = true,
154+
Indent = true
155+
};
156+
using (XmlWriter xw = XmlWriter.Create(stream, xws))
157+
{
158+
xmlDocument.Save(xw);
159+
}
151160

152-
Console.WriteLine($"{ConfigName} added in csproj!");
153161
}
162+
163+
Console.WriteLine($"{ConfigName} added in csproj!");
154164
return true;
155165
}
156166
}

0 commit comments

Comments
 (0)