Skip to content

Commit

Permalink
支持创建项目
Browse files Browse the repository at this point in the history
  • Loading branch information
lindexi committed Sep 10, 2024
1 parent f4f12cc commit 36e2f9f
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
48 changes: 48 additions & 0 deletions app/Tool/创建随机项目/WhitmanProjectCreator/Program.cs
Original file line number Diff line number Diff line change
@@ -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();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\package\WhitmanRandomIdentifier\WhitmanRandomIdentifier.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 36e2f9f

Please sign in to comment.