Rename
This commit is contained in:
37
DotNetSolutionTools.Core/FormatCsproj.cs
Normal file
37
DotNetSolutionTools.Core/FormatCsproj.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
namespace DotNetSolutionTools.Core;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user