Update Demo

This commit is contained in:
sunkaixuan
2019-01-17 18:17:59 +08:00
parent 8752a59ff3
commit 5ae75b1ce4

View File

@@ -35,6 +35,7 @@ namespace SugarCodeGeneration.Codes
public static void AddCsproj(string classPath, string projectName) public static void AddCsproj(string classPath, string projectName)
{ {
CreateProject(projectName);
var classDirectory = Methods.GetSlnPath + "\\" + projectName + "\\" + classPath.TrimStart('\\'); var classDirectory = Methods.GetSlnPath + "\\" + projectName + "\\" + classPath.TrimStart('\\');
if (FileHelper.IsExistDirectory(classDirectory) == false) if (FileHelper.IsExistDirectory(classDirectory) == false)
{ {
@@ -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"; var templatePath = GetCurrentProjectPath + "/Template/Project.txt";
string project = System.IO.File.ReadAllText(templatePath).Replace("@pid", Guid.NewGuid().ToString()); //从文件中读出模板内容 string project = System.IO.File.ReadAllText(templatePath).Replace("@pid", Guid.NewGuid().ToString()); //从文件中读出模板内容
//FileHelper 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);
}
} }
} }
} }