From f01c20570be76cc25c4535d934b1082f1bd4af6e Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Tue, 21 Jan 2020 01:44:47 +0100 Subject: [PATCH] Output: Create Visual Studio .csproj files when using --project (Project References are not currently resolved) --- Il2CppDumper/Il2CppCSharpDumper.cs | 15 +++++++++++++-- Il2CppDumper/Program.cs | 9 ++++++--- Il2CppDumper/Properties/Resources.resx | 2 +- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Il2CppDumper/Il2CppCSharpDumper.cs b/Il2CppDumper/Il2CppCSharpDumper.cs index 68ef99e..5b7a104 100644 --- a/Il2CppDumper/Il2CppCSharpDumper.cs +++ b/Il2CppDumper/Il2CppCSharpDumper.cs @@ -102,7 +102,7 @@ namespace Il2CppInspector } // Create a Visual Studio solution - public void WriteSolution(string outPath) { + public void WriteSolution(string outPath, string unityPath, string unityAssembliesPath) { // Required settings MustCompile = true; @@ -116,10 +116,12 @@ namespace Il2CppInspector foreach (var asm in assemblies) { var guid = Guid.NewGuid(); var name = asm.ShortName.Replace(".dll", ""); + var csProjFile = $"{name}\\{name}.csproj"; + var def = Resources.SlnProjectDefinition .Replace("%PROJECTGUID%", guid.ToString()) .Replace("%PROJECTNAME%", name) - .Replace("%CSPROJRELATIVEPATH%", $"{name}\\{name}.csproj"); + .Replace("%CSPROJRELATIVEPATH%", csProjFile); slnProjectDefs.Append(def); @@ -127,6 +129,15 @@ namespace Il2CppInspector .Replace("%PROJECTGUID%", guid.ToString()); 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 diff --git a/Il2CppDumper/Program.cs b/Il2CppDumper/Program.cs index 987a030..a494db3 100644 --- a/Il2CppDumper/Program.cs +++ b/Il2CppDumper/Program.cs @@ -108,9 +108,12 @@ namespace Il2CppInspector } // Creating a Visual Studio solution requires Unity assembly references + var unityPath = string.Empty; + var unityAssembliesPath = string.Empty; + if (options.CreateSolution) { - var unityPath = FindPath(options.UnityPath); - var unityAssembliesPath = FindPath(options.UnityAssembliesPath); + unityPath = FindPath(options.UnityPath); + unityAssembliesPath = FindPath(options.UnityAssembliesPath); if (!Directory.Exists(unityPath)) { Console.Error.WriteLine($"Unity path {unityPath} does not exist"); @@ -167,7 +170,7 @@ namespace Il2CppInspector csOut += imageSuffix; if (options.CreateSolution) { - writer.WriteSolution(csOut); + writer.WriteSolution(csOut, unityPath, unityAssembliesPath); continue; } diff --git a/Il2CppDumper/Properties/Resources.resx b/Il2CppDumper/Properties/Resources.resx index 35b493b..9e0c01e 100644 --- a/Il2CppDumper/Properties/Resources.resx +++ b/Il2CppDumper/Properties/Resources.resx @@ -126,7 +126,7 @@ <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProjectGuid>%PROJECTGUID%</ProjectGuid> + <ProjectGuid>{%PROJECTGUID%}</ProjectGuid> <!--<ProductVersion/>--> <!--<SchemaVersion/>--> <OutputType>Library</OutputType>