From 5ae75b1ce48a1aa052cca107c28f23fb31c8da1d Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Thu, 17 Jan 2019 18:17:59 +0800 Subject: [PATCH] Update Demo --- .../SugarCodeGeneration/Codes/Methods.cs | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Src/Asp.Net/SugarCodeGeneration/Codes/Methods.cs b/Src/Asp.Net/SugarCodeGeneration/Codes/Methods.cs index 6d17e3515..5398eac2b 100644 --- a/Src/Asp.Net/SugarCodeGeneration/Codes/Methods.cs +++ b/Src/Asp.Net/SugarCodeGeneration/Codes/Methods.cs @@ -35,7 +35,8 @@ namespace SugarCodeGeneration.Codes public static void AddCsproj(string classPath, string projectName) { - var classDirectory = Methods.GetSlnPath + "\\" + projectName + "\\" + classPath.TrimStart('\\'); + CreateProject(projectName); + var classDirectory = Methods.GetSlnPath + "\\" + projectName + "\\" + classPath.TrimStart('\\'); if (FileHelper.IsExistDirectory(classDirectory) == false) { FileHelper.CreateDirectory(classDirectory); @@ -90,11 +91,26 @@ namespace SugarCodeGeneration.Codes } - public static void CreateProject(string name) { + public static void CreateProject(string name) + { var templatePath = GetCurrentProjectPath + "/Template/Project.txt"; - string project = System.IO.File.ReadAllText(templatePath).Replace("@pid",Guid.NewGuid().ToString()); //从文件中读出模板内容 - //FileHelper + string project = System.IO.File.ReadAllText(templatePath).Replace("@pid", Guid.NewGuid().ToString()); //从文件中读出模板内容 + var projectPath = GetSlnPath + "\\" + name + "\\" + name + ".csproj"; + var projectDic = GetSlnPath + "\\" + name + "\\"; + var binDic = GetSlnPath + "\\" + name + "\\bin"; + if (!FileHelper.IsExistFile(projectPath)) + { + if (!FileHelper.IsExistDirectory(projectDic)) + { + FileHelper.CreateDirectory(projectDic); + } + if (!FileHelper.IsExistDirectory(binDic)) + { + FileHelper.CreateDirectory(binDic); + } + FileHelper.CreateFile(projectPath,project,System.Text.Encoding.UTF8); + } } } }