From e82626ded56a043676fadc5dc7e08158e2c1b586 Mon Sep 17 00:00:00 2001 From: nsnail Date: Thu, 8 Dec 2022 17:20:48 +0800 Subject: [PATCH] --- add-meta-files-to-sln.csx | 14 ++++++++++++++ dot.sln | 32 +++++++++++++++++--------------- 2 files changed, 31 insertions(+), 15 deletions(-) create mode 100644 add-meta-files-to-sln.csx diff --git a/add-meta-files-to-sln.csx b/add-meta-files-to-sln.csx new file mode 100644 index 0000000..b378f00 --- /dev/null +++ b/add-meta-files-to-sln.csx @@ -0,0 +1,14 @@ +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); \ No newline at end of file diff --git a/dot.sln b/dot.sln index 74aff93..9fcfc80 100644 --- a/dot.sln +++ b/dot.sln @@ -7,22 +7,24 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dot", "src\dot.csproj", "{E EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "meta", "meta", "{AD79881E-74D9-4EC7-AFE9-82D10CD32C3A}" ProjectSection(SolutionItems) = preProject - .gitignore = .gitignore - dot.sln.DotSettings = dot.sln.DotSettings - .gitattributes = .gitattributes - .editorconfig = .editorconfig - LICENSE = LICENSE - README.md = README.md - README.zh-CN.md = README.zh-CN.md - Directory.Build.props = Directory.Build.props - global.json = global.json - dotnet-tools.json = dotnet-tools.json - build.ps1 = build.ps1 - .tgitconfig = .tgitconfig - git-clean.ps1 = git-clean.ps1 - code-format.cmd = code-format.cmd - GenerateResx.targets = GenerateResx.targets + .editorconfig = .editorconfig + .gitattributes = .gitattributes + .gitignore = .gitignore + .tgitconfig = .tgitconfig + add-meta-files-to-sln.csx = add-meta-files-to-sln.csx + build.ps1 = build.ps1 code-cleanup-on-save.csx = code-cleanup-on-save.csx + code-format.cmd = code-format.cmd + Directory.Build.props = Directory.Build.props + dot.sln.DotSettings = dot.sln.DotSettings + dotnet-tools.json = dotnet-tools.json + GenerateResx.targets = GenerateResx.targets + git-clean.ps1 = git-clean.ps1 + global.json = global.json + LICENSE = LICENSE + README.md = README.md + README.zh-CN.md = README.zh-CN.md + safe-delete-unused-resx.ahk = safe-delete-unused-resx.ahk EndProjectSection EndProject Global