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(),
|
Guid = System.Guid.NewGuid().ToString("B").ToUpper(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Save(project, projectFilePath);
|
||||||
|
|
||||||
return true;
|
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)
|
public static void GenerateSolution(string projectPath, Project project, out string solutionPath)
|
||||||
{
|
{
|
||||||
// Clear files.
|
// Clear files.
|
||||||
string[] csProjectFiles = Directory.GetFiles(projectPath, CSProjFileName, SearchOption.TopDirectoryOnly);
|
string[] csProjectFiles = Directory.GetFiles(projectPath, $"*{CSProjFileName}", SearchOption.TopDirectoryOnly);
|
||||||
foreach (string csProjFile in csProjectFiles)
|
foreach (string csProjFile in csProjectFiles)
|
||||||
{
|
{
|
||||||
File.Delete(csProjFile);
|
File.Delete(csProjFile);
|
||||||
@ -103,7 +103,7 @@ public static void GenerateSolution(string projectPath, Project project, out str
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate solution.
|
// Generate solution.
|
||||||
string[] csProjPaths = Directory.GetFiles(projectPath, CSProjFileName, SearchOption.TopDirectoryOnly);
|
string[] csProjPaths = Directory.GetFiles(projectPath, $"*{CSProjFileName}", SearchOption.TopDirectoryOnly);
|
||||||
string[] csProjGuids = new string[csProjPaths.Length];
|
string[] csProjGuids = new string[csProjPaths.Length];
|
||||||
for (int i = 0; i < csProjPaths.Length; i++)
|
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 csProjPath = csProjPaths[i];
|
||||||
string projectGuid = csProjGuids[i];
|
string projectGuid = csProjGuids[i];
|
||||||
string projectName = Path.GetFileNameWithoutExtension(csProjPath);
|
string projectName = Path.GetFileNameWithoutExtension(csProjPath);
|
||||||
|
string projectRelativePath = Path.GetRelativePath(projectPath, csProjPath);
|
||||||
// FAE04EC0-301F-11D3-BF4B-00C04F79EFBC for C# projects.
|
// 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");
|
solutionContent.AppendLine("EndProject");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +224,7 @@ private static void GenerateCSProject(string csProjectFilePath, string projectPa
|
|||||||
|
|
||||||
projectContent.AppendLine("</Project>");
|
projectContent.AppendLine("</Project>");
|
||||||
|
|
||||||
string projectName = csProject.Name + ".Runtime.csproj";
|
string projectName = csProject.Name + ".csproj";
|
||||||
string filePath = Path.Combine(projectPath, projectName);
|
string filePath = Path.Combine(projectPath, projectName);
|
||||||
File.WriteAllText(filePath, projectContent.ToString());
|
File.WriteAllText(filePath, projectContent.ToString());
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,12 @@ internal static bool Open(string path)
|
|||||||
ProjectFilePath = path;
|
ProjectFilePath = path;
|
||||||
ProjectPath = Path.GetDirectoryName(path);
|
ProjectPath = Path.GetDirectoryName(path);
|
||||||
|
|
||||||
|
string projectSolutionFilePath = Path.Combine(ProjectPath, Project.Name + ".sln");
|
||||||
|
if (File.Exists(projectSolutionFilePath))
|
||||||
|
{
|
||||||
|
ProjectSolutionFilePath = projectSolutionFilePath;
|
||||||
|
}
|
||||||
|
|
||||||
SetupDefaultFolders();
|
SetupDefaultFolders();
|
||||||
Compile();
|
Compile();
|
||||||
|
|
||||||
@ -112,6 +118,13 @@ private static void SetupDefaultFolders()
|
|||||||
Directory.CreateDirectory(scriptsRuntimePath);
|
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");
|
string tempPath = Path.Combine(ProjectPath, "Temp");
|
||||||
if (!Directory.Exists(tempPath))
|
if (!Directory.Exists(tempPath))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user