Output: Add <ProjectReference> elements in .csproj files
This commit is contained in:
@@ -130,12 +130,27 @@ namespace Il2CppInspector
|
|||||||
|
|
||||||
slnProjectConfigs.Append(config);
|
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
|
// Create a .csproj file using the project Guid
|
||||||
var csProj = Resources.CsProjTemplate
|
var csProj = Resources.CsProjTemplate
|
||||||
.Replace("%PROJECTGUID%", guid.ToString())
|
.Replace("%PROJECTGUID%", guid.ToString())
|
||||||
.Replace("%ASSEMBLYNAME%", name)
|
.Replace("%ASSEMBLYNAME%", name)
|
||||||
.Replace("%UNITYPATH%", unityPath)
|
.Replace("%UNITYPATH%", unityPath)
|
||||||
.Replace("%SCRIPTASSEMBLIES%", unityAssembliesPath);
|
.Replace("%SCRIPTASSEMBLIES%", unityAssembliesPath)
|
||||||
|
.Replace("%PROJECTREFERENCES%", referenceXml);
|
||||||
|
|
||||||
File.WriteAllText($"{outPath}\\{csProjFile}", csProj);
|
File.WriteAllText($"{outPath}\\{csProjFile}", csProj);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -733,6 +733,9 @@
|
|||||||
<HintPath>%UNITYPATH%/Editor/Data/NetStandard/compat/2.0.0/shims/netfx/System.Xml.Serialization.dll</HintPath>
|
<HintPath>%UNITYPATH%/Editor/Data/NetStandard/compat/2.0.0/shims/netfx/System.Xml.Serialization.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
%PROJECTREFERENCES%
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<!--<Target Name="GenerateTargetFrameworkMonikerAttribute"/>-->
|
<!--<Target Name="GenerateTargetFrameworkMonikerAttribute"/>-->
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.Targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.Targets" />
|
||||||
|
|||||||
Reference in New Issue
Block a user