Generate solution file
This commit is contained in:
parent
f978c49532
commit
2afbd9defe
@ -42,11 +42,7 @@ internal static bool Create(string path, string projectName)
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Create solution.
|
// Create solution.
|
||||||
if (!GenerateCSProjectFiles(path, projectConfig))
|
GenerateSolution(path, projectConfig);
|
||||||
{
|
|
||||||
Log.Error($"Generating cs project files failed!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
string projectFilePath = Path.Combine(path, projectFileName);
|
string projectFilePath = Path.Combine(path, projectFileName);
|
||||||
SaveProject(projectFilePath, projectConfig);
|
SaveProject(projectFilePath, projectConfig);
|
||||||
@ -106,13 +102,58 @@ internal static bool SaveProject(string path, ProjectConfig projectConfig)
|
|||||||
// Compile the project using the builder.
|
// Compile the project using the builder.
|
||||||
internal static bool CompileProject()
|
internal static bool CompileProject()
|
||||||
{
|
{
|
||||||
|
//GenerateSolution();
|
||||||
|
//dotnet build <sln>
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void GenerateSolution(string path, ProjectConfig projectConfig)
|
||||||
|
{
|
||||||
|
GenerateCSProjectFiles(path, projectConfig);
|
||||||
|
|
||||||
|
Log.Info("Generating solution file");
|
||||||
|
string solution =
|
||||||
|
$@"
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.10.35013.160
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project(""{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}"") = ""{projectConfig.Name}.Runtime"", ""{projectConfig.Name}.Runtime.csproj"", ""{{B04FAEF8-7D91-43A9-81C5-4BD3217B0C23}}""
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Test|x64 = Test|x64
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{{B04FAEF8-7D91-43A9-81C5-4BD3217B0C23}}.Test|x64.ActiveCfg = Test|x64
|
||||||
|
{{B04FAEF8-7D91-43A9-81C5-4BD3217B0C23}}.Test|x64.Build.0 = Test|x64
|
||||||
|
{{B04FAEF8-7D91-43A9-81C5-4BD3217B0C23}}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{{B04FAEF8-7D91-43A9-81C5-4BD3217B0C23}}.Release|x64.Build.0 = Release|x64
|
||||||
|
{{B04FAEF8-7D91-43A9-81C5-4BD3217B0C23}}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{{B04FAEF8-7D91-43A9-81C5-4BD3217B0C23}}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {{117DD74B-A4DC-48CE-B782-C7AE565A9270}}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
|
";
|
||||||
|
|
||||||
|
string solutionName = projectConfig.Name + ".sln";
|
||||||
|
string filePath = Path.Combine(path, solutionName);
|
||||||
|
|
||||||
|
File.WriteAllText(filePath, solution);
|
||||||
|
}
|
||||||
|
|
||||||
// Inspirered by https://github.com/ProwlEngine/Prowl/blob/main/Prowl.Editor/Project.cs
|
// Inspirered by https://github.com/ProwlEngine/Prowl/blob/main/Prowl.Editor/Project.cs
|
||||||
// Maybe the builder should do this?
|
// Maybe the builder should do this?
|
||||||
// When compiling the 'runtimeAssembly.Location' needs to be updated to where ever the one is that is being used.
|
// When compiling the 'runtimeAssembly.Location' needs to be updated to where ever the one is that is being used.
|
||||||
private static bool GenerateCSProjectFiles(string path, ProjectConfig projectConfig)
|
private static void GenerateCSProjectFiles(string path, ProjectConfig projectConfig)
|
||||||
{
|
{
|
||||||
Log.Info("Generating CS project files");
|
Log.Info("Generating CS project files");
|
||||||
|
|
||||||
@ -120,48 +161,52 @@ private static bool GenerateCSProjectFiles(string path, ProjectConfig projectCon
|
|||||||
Assembly runtimeAssembly = loadedAssemblies.FirstOrDefault(assembly => assembly.GetName().Name == "Nerfed.Runtime") ?? throw new Exception("Failed to find Runtime Assembly!");
|
Assembly runtimeAssembly = loadedAssemblies.FirstOrDefault(assembly => assembly.GetName().Name == "Nerfed.Runtime") ?? throw new Exception("Failed to find Runtime Assembly!");
|
||||||
|
|
||||||
string propertyGroup =
|
string propertyGroup =
|
||||||
$@"
|
$@"
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>disable</Nullable>
|
<Nullable>disable</Nullable>
|
||||||
<PublishAot>true</PublishAot>
|
<PublishAot>true</PublishAot>
|
||||||
<InvariantGlobalization>true</InvariantGlobalization>
|
<InvariantGlobalization>true</InvariantGlobalization>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
<Configurations>Debug;Test;Release</Configurations>
|
<Configurations>Debug;Test;Release</Configurations>
|
||||||
<Platforms>x64</Platforms>
|
<Platforms>x64</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="" '$(Configuration)|$(Platform)' == 'Debug|x64' "">
|
<PropertyGroup Condition="" '$(Configuration)|$(Platform)' == 'Debug|x64' "">
|
||||||
<DefineConstants>TRACE;LOG_INFO;PROFILING</DefineConstants>
|
<DefineConstants>TRACE;LOG_INFO;PROFILING</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="" '$(Configuration)|$(Platform)' == 'Test|x64' "">
|
<PropertyGroup Condition="" '$(Configuration)|$(Platform)' == 'Test|x64' "">
|
||||||
<DefineConstants>TRACE;LOG_ERROR;PROFILING</DefineConstants>
|
<DefineConstants>TRACE;LOG_ERROR;PROFILING</DefineConstants>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="" '$(Configuration)|$(Platform)' == 'Release|x64' "">
|
<PropertyGroup Condition="" '$(Configuration)|$(Platform)' == 'Release|x64' "">
|
||||||
<DefineConstants>TRACE;LOG_ERROR</DefineConstants>
|
<DefineConstants>TRACE;LOG_ERROR</DefineConstants>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
";
|
";
|
||||||
|
|
||||||
string runtimeProject =
|
string runtimeProject =
|
||||||
$@"
|
$@"
|
||||||
<Project Sdk=""Microsoft.NET.Sdk"">
|
<Project Sdk=""Microsoft.NET.Sdk"">
|
||||||
{propertyGroup}
|
{propertyGroup}
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include=""Nerfed.Runtime"">
|
<Compile Include=""/Content/Scripts/Runtime/**/*.cs""/>
|
||||||
<HintPath>{runtimeAssembly.Location}</HintPath>
|
</ItemGroup>
|
||||||
<Private>false</Private>
|
|
||||||
</Reference>
|
<ItemGroup>
|
||||||
</ItemGroup>
|
<Reference Include=""Nerfed.Runtime"">
|
||||||
</Project>
|
<HintPath>{runtimeAssembly.Location}</HintPath>
|
||||||
";
|
<Private>false</Private>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
|
";
|
||||||
|
|
||||||
string runtimeProjectName = projectConfig.Name + ".Runtime.csproj";
|
string runtimeProjectName = projectConfig.Name + ".Runtime.csproj";
|
||||||
string filePath = Path.Combine(path, runtimeProjectName);
|
string filePath = Path.Combine(path, runtimeProjectName);
|
||||||
@ -172,9 +217,6 @@ private static bool GenerateCSProjectFiles(string path, ProjectConfig projectCon
|
|||||||
Log.Info($"Generated runtime at {filePath}");
|
Log.Info($"Generated runtime at {filePath}");
|
||||||
|
|
||||||
// TODO: Editor project.
|
// TODO: Editor project.
|
||||||
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SetupDefaultFolders(string path)
|
private static void SetupDefaultFolders(string path)
|
||||||
@ -187,6 +229,16 @@ private static void SetupDefaultFolders(string path)
|
|||||||
Directory.CreateDirectory(contentPath);
|
Directory.CreateDirectory(contentPath);
|
||||||
}
|
}
|
||||||
ProjectContentDirectory = contentPath;
|
ProjectContentDirectory = contentPath;
|
||||||
|
string scriptsPath = Path.Combine(ProjectContentDirectory, "Scripts");
|
||||||
|
if (!Directory.Exists(scriptsPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(scriptsPath);
|
||||||
|
}
|
||||||
|
string scriptsRuntimePath = Path.Combine(scriptsPath, "Runtime");
|
||||||
|
if (!Directory.Exists(scriptsRuntimePath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(scriptsRuntimePath);
|
||||||
|
}
|
||||||
|
|
||||||
string tempPath = Path.Combine(path, "Temp");
|
string tempPath = Path.Combine(path, "Temp");
|
||||||
if (!Directory.Exists(tempPath))
|
if (!Directory.Exists(tempPath))
|
||||||
|
Loading…
Reference in New Issue
Block a user