Files
DotNetSolutionTools/SolutionParityChecker/FormatCsproj.cs
2023-08-30 18:59:41 +10:00

37 lines
887 B
C#

using System.Text;
using System.Xml;
namespace SolutionParityChecker;
public static class FormatCsproj
{
public static void FormatCsprojFile(string csprojFilePath)
{
using TextReader rd = new StreamReader(csprojFilePath, Encoding.Default);
XmlDocument doc = new XmlDocument();
doc.Load(rd);
if (rd != Console.In)
{
rd.Close();
}
using var wr = new StreamWriter(csprojFilePath, false, Encoding.Default);
var settings =
new XmlWriterSettings
{
Indent = true,
IndentChars = "\t",
NewLineOnAttributes = false,
OmitXmlDeclaration = true
};
using (var writer = XmlWriter.Create(wr, settings))
{
doc.WriteContentTo(writer);
writer.Close();
}
}
}