diff --git a/Il2CppDumper/Il2CppCSharpDumper.cs b/Il2CppDumper/Il2CppCSharpDumper.cs index 5b7a104..9dd38ba 100644 --- a/Il2CppDumper/Il2CppCSharpDumper.cs +++ b/Il2CppDumper/Il2CppCSharpDumper.cs @@ -130,12 +130,27 @@ namespace Il2CppInspector slnProjectConfigs.Append(config); + // Determine all the assemblies on which this assembly depends + var dependencyTypes = asm.DefinedTypes.SelectMany(t => t.GetAllTypeReferences()) + .Union(asm.CustomAttributes.SelectMany(a => a.AttributeType.GetAllTypeReferences())) + .Distinct(); + var dependencyAssemblies = dependencyTypes.Select(t => t.Assembly).Distinct() + .Except(new[] {asm}); + + // Only create project references to those assemblies actually output in our solution + dependencyAssemblies = dependencyAssemblies.Intersect(assemblies); + + var referenceXml = string.Concat(dependencyAssemblies.Select( + a => $@" " + "\n" + )); + // 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); + .Replace("%SCRIPTASSEMBLIES%", unityAssembliesPath) + .Replace("%PROJECTREFERENCES%", referenceXml); File.WriteAllText($"{outPath}\\{csProjFile}", csProj); } diff --git a/Il2CppDumper/Properties/Resources.resx b/Il2CppDumper/Properties/Resources.resx index 9e0c01e..83b30ea 100644 --- a/Il2CppDumper/Properties/Resources.resx +++ b/Il2CppDumper/Properties/Resources.resx @@ -733,6 +733,9 @@ <HintPath>%UNITYPATH%/Editor/Data/NetStandard/compat/2.0.0/shims/netfx/System.Xml.Serialization.dll</HintPath> </Reference> </ItemGroup> + <ItemGroup> +%PROJECTREFERENCES% + </ItemGroup> <!--<Target Name="GenerateTargetFrameworkMonikerAttribute"/>--> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.Targets" />