Skip to content

Commit f89bab3

Browse files
committed
Print some messages about locating KSPRoot
1 parent 0f99ba8 commit f89bab3

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

KSPCommon.props

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,40 @@
5252
<PropertyGroup>
5353
<!-- Relative path that must exist for a path to be a valid KSP Install-->
5454
<KSPRootIdentifier>$(ManagedRelativePath)/Assembly-CSharp.dll</KSPRootIdentifier>
55+
<KSPRootSource Condition="'$(KSPRoot)' != ''">property</KSPRootSource>
56+
</PropertyGroup>
5557

58+
<PropertyGroup Condition=" '$(KSPRoot)' == '' And '$(KSP_ROOT)' != '' ">
5659
<!-- Default KSPRoot to the "KSP_ROOT" environment variable if it exists -->
5760
<!-- Doing this skips any checks for a valid KSP install so be careful! -->
58-
<KSPRoot Condition=" '$(KSPRoot)' == '' And '$(KSP_ROOT)' != '' ">$(KSP_ROOT)</KSPRoot>
61+
<KSPRoot >$(KSP_ROOT)</KSPRoot>
62+
<KSPRootSource>environment variable</KSPRootSource>
63+
</PropertyGroup>
64+
<ItemGroup>
65+
<KSPRootCandidate Include="$(SolutionDir)KSP" source="solution directory"/>
66+
<KSPRootCandidate Include="$(ReferencePath)" source="reference path"/>
67+
<KSPRootCandidate Include="$(SteamKSPRoot)" source="steam"/>
68+
</ItemGroup>
5969

70+
<PropertyGroup Condition=" '$(KSPRoot)' == '' And Exists('$(SolutionDir)KSP/$(KSPRootIdentifier)') ">
6071
<!-- Look for KSP install in Solution dir -->
61-
<KSPRoot Condition=" '$(KSPRoot)' == '' And Exists('$(SolutionDir)KSP/$(KSPRootIdentifier)') ">$(SolutionDir)KSP</KSPRoot>
72+
<KSPRoot >$(SolutionDir)KSP</KSPRoot>
73+
<KSPRootSource>solution directory</KSPRootSource>
74+
</PropertyGroup>
6275

76+
<PropertyGroup Condition=" '$(KSPRoot)' == '' And Exists('$(ReferencePath)/$(KSPRootIdentifier)') ">
6377
<!-- Look for KSP install in ReferencePath -->
64-
<KSPRoot Condition=" '$(KSPRoot)' == '' And Exists('$(ReferencePath)/$(KSPRootIdentifier)') ">$(ReferencePath)</KSPRoot>
78+
<KSPRoot>$(ReferencePath)</KSPRoot>
79+
<KSPRootSource>reference path</KSPRootSource>
80+
</PropertyGroup>
6581

82+
<PropertyGroup Condition=" '$(KSPRoot)' == '' And Exists('$(SteamKSPRoot)/$(KSPRootIdentifier)') ">
6683
<!-- Look for KSP steam install-->
67-
<KSPRoot Condition=" '$(KSPRoot)' == '' And Exists('$(SteamKSPRoot)/$(KSPRootIdentifier)') ">$(SteamKSPRoot)</KSPRoot>
84+
<KSPRoot>$(SteamKSPRoot)</KSPRoot>
85+
<KSPRootSource>steam</KSPRootSource>
86+
</PropertyGroup>
6887

88+
<PropertyGroup>
6989
<!-- Calculate ManagedPath -->
7090
<ManagedPath>$(KSPRoot)/$(ManagedRelativePath)</ManagedPath>
7191
</PropertyGroup>

KSPCommon.targets

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,19 @@
1010

1111
<!--Custom Targets-->
1212

13-
<Target Name="CheckForKSPRoot" BeforeTargets="ResolveReferences" Condition="'$(KSPRoot)' == ''">
14-
<Error Text="KSPBuildTools was unable to find a KSP installation. Please set the ReferencePath or KSPRoot property in your csproj.user file to a valid KSP installation directory (the one with GameData in it)"/>
15-
<Message Text="Found KSPRoot at $(KSPRoot)" Importance="low"/>
13+
<Target Name="CheckForKSPRoot" BeforeTargets="ResolveReferences">
14+
<Error Text="KSPBuildTools was unable to find a KSP installation. Please set the ReferencePath or KSPRoot property
15+
in your csproj.user file to a valid KSP installation directory (the one with GameData in it)
16+
17+
See https://kspbuildtools.readthedocs.io/en/latest/msbuild/getting-started.html#locating-your-ksp-install for more information"
18+
Condition="'$(KSPRoot)' == ''"/>
19+
<ItemGroup>
20+
<_KSPRootMessage Include="KSPRoot Candidates:"/>
21+
<_KSPRootMessage Include="Candidate: %(KSPRootCandidate.source) from %(KSPRootCandidate.identity)"/>
22+
<_KSPRootMessage Include="Chosen KSPRoot: $(KSPRoot) in $(KSPRootSource)" Condition="'$(KSPRoot)' != ''"/>
23+
</ItemGroup>
24+
<Message Text="@(_KSPRootMessage, '%0a')" Importance="normal"/>
25+
1626
</Target>
1727

1828
<!-- Copy output files to mod folder -->

0 commit comments

Comments
 (0)