project and solution generation
This commit is contained in:
parent
36a134170a
commit
546b7feca7
@ -29,6 +29,8 @@ public static bool Create(string projectFilePath, string name, out CSProject pro
|
||||
Guid = System.Guid.NewGuid().ToString("B").ToUpper(),
|
||||
};
|
||||
|
||||
Save(project, projectFilePath);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ public static bool Compile(string projectFilePath, string configuration = "Debug
|
||||
public static void GenerateSolution(string projectPath, Project project, out string solutionPath)
|
||||
{
|
||||
// Clear files.
|
||||
string[] csProjectFiles = Directory.GetFiles(projectPath, CSProjFileName, SearchOption.TopDirectoryOnly);
|
||||
string[] csProjectFiles = Directory.GetFiles(projectPath, $"*{CSProjFileName}", SearchOption.TopDirectoryOnly);
|
||||
foreach (string csProjFile in csProjectFiles)
|
||||
{
|
||||
File.Delete(csProjFile);
|
||||
@ -103,7 +103,7 @@ public static void GenerateSolution(string projectPath, Project project, out str
|
||||
}
|
||||
|
||||
// Generate solution.
|
||||
string[] csProjPaths = Directory.GetFiles(projectPath, CSProjFileName, SearchOption.TopDirectoryOnly);
|
||||
string[] csProjPaths = Directory.GetFiles(projectPath, $"*{CSProjFileName}", SearchOption.TopDirectoryOnly);
|
||||
string[] csProjGuids = new string[csProjPaths.Length];
|
||||
for (int i = 0; i < csProjPaths.Length; i++)
|
||||
{
|
||||
@ -124,8 +124,9 @@ public static void GenerateSolution(string projectPath, Project project, out str
|
||||
string csProjPath = csProjPaths[i];
|
||||
string projectGuid = csProjGuids[i];
|
||||
string projectName = Path.GetFileNameWithoutExtension(csProjPath);
|
||||
string projectRelativePath = Path.GetRelativePath(projectPath, csProjPath);
|
||||
// FAE04EC0-301F-11D3-BF4B-00C04F79EFBC for C# projects.
|
||||
solutionContent.AppendLine($"Project(\"{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}\") = \"{projectName}\", \"{csProjPath}\", \"{projectGuid}\"");
|
||||
solutionContent.AppendLine($"Project(\"{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}\") = \"{projectName}\", \"{projectRelativePath}\", \"{projectGuid}\"");
|
||||
solutionContent.AppendLine("EndProject");
|
||||
}
|
||||
|
||||
@ -223,7 +224,7 @@ private static void GenerateCSProject(string csProjectFilePath, string projectPa
|
||||
|
||||
projectContent.AppendLine("</Project>");
|
||||
|
||||
string projectName = csProject.Name + ".Runtime.csproj";
|
||||
string projectName = csProject.Name + ".csproj";
|
||||
string filePath = Path.Combine(projectPath, projectName);
|
||||
File.WriteAllText(filePath, projectContent.ToString());
|
||||
}
|
||||
|
@ -38,6 +38,12 @@ internal static bool Open(string path)
|
||||
Project = project;
|
||||
ProjectFilePath = path;
|
||||
ProjectPath = Path.GetDirectoryName(path);
|
||||
|
||||
string projectSolutionFilePath = Path.Combine(ProjectPath, Project.Name + ".sln");
|
||||
if (File.Exists(projectSolutionFilePath))
|
||||
{
|
||||
ProjectSolutionFilePath = projectSolutionFilePath;
|
||||
}
|
||||
|
||||
SetupDefaultFolders();
|
||||
Compile();
|
||||
@ -112,6 +118,13 @@ private static void SetupDefaultFolders()
|
||||
Directory.CreateDirectory(scriptsRuntimePath);
|
||||
}
|
||||
|
||||
// Test create csproject.
|
||||
string gameplayRuntimePath = Path.Combine(scriptsRuntimePath, ".csproject");
|
||||
if (!File.Exists(gameplayRuntimePath))
|
||||
{
|
||||
Compiler.CSProject.Create(gameplayRuntimePath, "Gameplay", out Compiler.CSProject project);
|
||||
}
|
||||
|
||||
string tempPath = Path.Combine(ProjectPath, "Temp");
|
||||
if (!Directory.Exists(tempPath))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user