Output: Add <ProjectReference> elements in .csproj files

This commit is contained in:
Katy Coe
2020-01-21 02:38:45 +01:00
parent f01c20570b
commit ff90ab7c96
2 changed files with 19 additions and 1 deletions

View File

@@ -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 => $@" <ProjectReference Include=""..\{a.ShortName.Replace(".dll", "")}\{a.ShortName.Replace(".dll", "")}.csproj""/>" + "\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);
}

View File

@@ -733,6 +733,9 @@
&lt;HintPath&gt;%UNITYPATH%/Editor/Data/NetStandard/compat/2.0.0/shims/netfx/System.Xml.Serialization.dll&lt;/HintPath&gt;
&lt;/Reference&gt;
&lt;/ItemGroup&gt;
&lt;ItemGroup&gt;
%PROJECTREFERENCES%
&lt;/ItemGroup&gt;
&lt;!--&lt;Target Name="GenerateTargetFrameworkMonikerAttribute"/&gt;--&gt;
&lt;Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.Targets" /&gt;