From 36e2f9f684588b52a8ade8755a8e8597cc67ff84 Mon Sep 17 00:00:00 2001 From: lindexi Date: Tue, 10 Sep 2024 14:48:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=88=9B=E5=BB=BA=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WhitmanProjectCreator/Program.cs" | 48 +++++++++++++++++++ .../WhitmanProjectCreator.csproj" | 14 ++++++ .../WhitmanProjectCreator.sln" | 27 +++++++++++ 3 files changed, 89 insertions(+) create mode 100644 "app/Tool/\345\210\233\345\273\272\351\232\217\346\234\272\351\241\271\347\233\256/WhitmanProjectCreator/Program.cs" create mode 100644 "app/Tool/\345\210\233\345\273\272\351\232\217\346\234\272\351\241\271\347\233\256/WhitmanProjectCreator/WhitmanProjectCreator.csproj" create mode 100644 "app/Tool/\345\210\233\345\273\272\351\232\217\346\234\272\351\241\271\347\233\256/WhitmanProjectCreator/WhitmanProjectCreator.sln" diff --git "a/app/Tool/\345\210\233\345\273\272\351\232\217\346\234\272\351\241\271\347\233\256/WhitmanProjectCreator/Program.cs" "b/app/Tool/\345\210\233\345\273\272\351\232\217\346\234\272\351\241\271\347\233\256/WhitmanProjectCreator/Program.cs" new file mode 100644 index 0000000..c85a5ce --- /dev/null +++ "b/app/Tool/\345\210\233\345\273\272\351\232\217\346\234\272\351\241\271\347\233\256/WhitmanProjectCreator/Program.cs" @@ -0,0 +1,48 @@ +// See https://aka.ms/new-console-template for more information + +using System.Diagnostics; + +using Lindexi.Src.WhitmanRandomIdentifier; + +var projectType = "wpf"; +if (args.Length > 0) +{ + projectType = args[0]; +} + +var randomIdentifier = new RandomIdentifier(); + +var folderName = randomIdentifier.Generate(true); + +var folderPath = Path.Join(Environment.CurrentDirectory, folderName); + +Directory.CreateDirectory(folderPath); + +RunCommand($"dotnet new {projectType}", folderPath); +RunCommand($"dotnet new sln", folderPath); +RunCommand($"dotnet sln add .", folderPath); + +var slnFile = Path.Join(folderPath, $"{folderName}.sln"); +Process.Start(new ProcessStartInfo(slnFile) { UseShellExecute = true }); + + +void RunCommand(string command, string workingDirectory) +{ + var processStartInfo = new ProcessStartInfo("cmd") + { + RedirectStandardInput = true, + //RedirectStandardOutput = true, + //RedirectStandardError = true, + UseShellExecute = false, + //CreateNoWindow = true, + WorkingDirectory = workingDirectory, + }; + + using var process = new Process(); + process.StartInfo = processStartInfo; + process.Start(); + + process.StandardInput.WriteLine(command); + process.StandardInput.WriteLine("exit"); + process.WaitForExit(); +} diff --git "a/app/Tool/\345\210\233\345\273\272\351\232\217\346\234\272\351\241\271\347\233\256/WhitmanProjectCreator/WhitmanProjectCreator.csproj" "b/app/Tool/\345\210\233\345\273\272\351\232\217\346\234\272\351\241\271\347\233\256/WhitmanProjectCreator/WhitmanProjectCreator.csproj" new file mode 100644 index 0000000..fc73214 --- /dev/null +++ "b/app/Tool/\345\210\233\345\273\272\351\232\217\346\234\272\351\241\271\347\233\256/WhitmanProjectCreator/WhitmanProjectCreator.csproj" @@ -0,0 +1,14 @@ + + + + Exe + net9.0 + enable + enable + + + + + + + diff --git "a/app/Tool/\345\210\233\345\273\272\351\232\217\346\234\272\351\241\271\347\233\256/WhitmanProjectCreator/WhitmanProjectCreator.sln" "b/app/Tool/\345\210\233\345\273\272\351\232\217\346\234\272\351\241\271\347\233\256/WhitmanProjectCreator/WhitmanProjectCreator.sln" new file mode 100644 index 0000000..6ded9fb --- /dev/null +++ "b/app/Tool/\345\210\233\345\273\272\351\232\217\346\234\272\351\241\271\347\233\256/WhitmanProjectCreator/WhitmanProjectCreator.sln" @@ -0,0 +1,27 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WhitmanProjectCreator", "WhitmanProjectCreator.csproj", "{8FBD4516-D5FE-4413-88AA-A8141258A994}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WhitmanRandomIdentifier", "..\..\..\..\package\WhitmanRandomIdentifier\WhitmanRandomIdentifier.csproj", "{46C0917E-A95E-4590-824E-60AAB949816B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {46C0917E-A95E-4590-824E-60AAB949816B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {46C0917E-A95E-4590-824E-60AAB949816B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {46C0917E-A95E-4590-824E-60AAB949816B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {46C0917E-A95E-4590-824E-60AAB949816B}.Release|Any CPU.Build.0 = Release|Any CPU + {8FBD4516-D5FE-4413-88AA-A8141258A994}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8FBD4516-D5FE-4413-88AA-A8141258A994}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8FBD4516-D5FE-4413-88AA-A8141258A994}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8FBD4516-D5FE-4413-88AA-A8141258A994}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal