Skip to content

Commit 769b65e

Browse files
committed
add ability to declare mod dependencies with ModReference items
1 parent 1c41d5f commit 769b65e

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

KSPCommon.targets

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161

6262
<ItemGroup>
6363
<ResolveAssemblyReferencesDependsOn Include="CKANInstall"/>
64+
<ResolveAssemblyReferencesDependsOn Include="KSPBTGenerateAssemblyReferences"/>
6465
</ItemGroup>
6566

6667
<!-- Execute generated CKAN command list -->
@@ -72,6 +73,23 @@
7273
<Delete Files="$(CKANCommandFile)"/>
7374
</Target>
7475

76+
<!--
77+
Convert ModReference items to Reference items. This allows KSPBTInstallRoot to be evaluated
78+
after the csproj body or in a target, giving greater flexibility.
79+
80+
The value of the item should be name of the assembly as defined in its KSPAssembly attribute.
81+
The DLLPath attribute is the path to the DLL relative to the installation root, e.g. "GameData/CoolMod/mod.dll"
82+
-->
83+
<Target Name="KSPBTGenerateAssemblyReferences" BeforeTargets="ResolveAssemblyReferences"
84+
Inputs="@(ModReference)" Outputs="@(Reference)">
85+
<ItemGroup>
86+
<Reference Include="@(ModReference->'$(KSPBTGameRoot)/%(DLLPath)')">
87+
<KSPAssemblyName>%(ModReference.identity)</KSPAssemblyName>
88+
</Reference>
89+
</ItemGroup>
90+
</Target>
91+
92+
7593
<!-- For use like so: `msbuild -t:"GetRequiredExternalTools" -verbosity:minimal -nologo`, then pipe into your destination of choice -->
7694
<Target Name="GetRequiredExternalTools">
7795
<ItemGroup>

0 commit comments

Comments
 (0)