mirror of
https://github.com/nsnail/NSCodeAnalysis.git
synced 2025-04-12 22:42:51 +08:00
14 lines
610 B
C#
14 lines
610 B
C#
using System.Text.RegularExpressions;
|
|
|
|
var slnFile = Directory.GetFiles(@".", "*.sln").First();
|
|
var content = File.ReadAllText(slnFile);
|
|
content = Regex.Replace(content,@"ProjectSection\(SolutionItems\) = preProject(?:.|\n)*?EndProjectSection",
|
|
$"""
|
|
ProjectSection(SolutionItems) = preProject
|
|
{string.Join('\n',
|
|
Directory.GetFiles(@".", "*").Where(x => !x.EndsWith(".sln"))
|
|
.Select(x=>$"\t\t{Path.GetFileName(x)} = {Path.GetFileName(x)}"))}
|
|
{'\t'}EndProjectSection
|
|
""");
|
|
Console.WriteLine(content);
|
|
File.WriteAllText(slnFile, content); |