Output: Create Visual Studio .csproj files when using --project (Project References are not currently resolved)

This commit is contained in:
Katy Coe
2020-01-21 01:44:47 +01:00
parent a136f49603
commit f01c20570b
3 changed files with 20 additions and 6 deletions

View File

@@ -102,7 +102,7 @@ namespace Il2CppInspector
} }
// Create a Visual Studio solution // Create a Visual Studio solution
public void WriteSolution(string outPath) { public void WriteSolution(string outPath, string unityPath, string unityAssembliesPath) {
// Required settings // Required settings
MustCompile = true; MustCompile = true;
@@ -116,10 +116,12 @@ namespace Il2CppInspector
foreach (var asm in assemblies) { foreach (var asm in assemblies) {
var guid = Guid.NewGuid(); var guid = Guid.NewGuid();
var name = asm.ShortName.Replace(".dll", ""); var name = asm.ShortName.Replace(".dll", "");
var csProjFile = $"{name}\\{name}.csproj";
var def = Resources.SlnProjectDefinition var def = Resources.SlnProjectDefinition
.Replace("%PROJECTGUID%", guid.ToString()) .Replace("%PROJECTGUID%", guid.ToString())
.Replace("%PROJECTNAME%", name) .Replace("%PROJECTNAME%", name)
.Replace("%CSPROJRELATIVEPATH%", $"{name}\\{name}.csproj"); .Replace("%CSPROJRELATIVEPATH%", csProjFile);
slnProjectDefs.Append(def); slnProjectDefs.Append(def);
@@ -127,6 +129,15 @@ namespace Il2CppInspector
.Replace("%PROJECTGUID%", guid.ToString()); .Replace("%PROJECTGUID%", guid.ToString());
slnProjectConfigs.Append(config); slnProjectConfigs.Append(config);
// Create a .csproj file using the project Guid
var csProj = Resources.CsProjTemplate
.Replace("%PROJECTGUID%", guid.ToString())
.Replace("%ASSEMBLYNAME%", name)
.Replace("%UNITYPATH%", unityPath)
.Replace("%SCRIPTASSEMBLIES%", unityAssembliesPath);
File.WriteAllText($"{outPath}\\{csProjFile}", csProj);
} }
// Merge everything into .sln file // Merge everything into .sln file

View File

@@ -108,9 +108,12 @@ namespace Il2CppInspector
} }
// Creating a Visual Studio solution requires Unity assembly references // Creating a Visual Studio solution requires Unity assembly references
var unityPath = string.Empty;
var unityAssembliesPath = string.Empty;
if (options.CreateSolution) { if (options.CreateSolution) {
var unityPath = FindPath(options.UnityPath); unityPath = FindPath(options.UnityPath);
var unityAssembliesPath = FindPath(options.UnityAssembliesPath); unityAssembliesPath = FindPath(options.UnityAssembliesPath);
if (!Directory.Exists(unityPath)) { if (!Directory.Exists(unityPath)) {
Console.Error.WriteLine($"Unity path {unityPath} does not exist"); Console.Error.WriteLine($"Unity path {unityPath} does not exist");
@@ -167,7 +170,7 @@ namespace Il2CppInspector
csOut += imageSuffix; csOut += imageSuffix;
if (options.CreateSolution) { if (options.CreateSolution) {
writer.WriteSolution(csOut); writer.WriteSolution(csOut, unityPath, unityAssembliesPath);
continue; continue;
} }

View File

@@ -126,7 +126,7 @@
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>%PROJECTGUID%</ProjectGuid> <ProjectGuid>{%PROJECTGUID%}</ProjectGuid>
<!--<ProductVersion/>--> <!--<ProductVersion/>-->
<!--<SchemaVersion/>--> <!--<SchemaVersion/>-->
<OutputType>Library</OutputType> <OutputType>Library</OutputType>