Skip to content

Commit cf333d2

Browse files
committed
move the last of the GameRoot logic to targets
This means that everything can be set in .csproj.user without hacks
1 parent 0b82269 commit cf333d2

2 files changed

Lines changed: 45 additions & 49 deletions

File tree

KSPCommon.props

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -56,62 +56,13 @@
5656
<_KSPBT_SteamGameRoot Condition=" $([MSBuild]::IsOsPlatform('OSX')) ">$(HOME)/Library/Application Support/Steam/steamapps/common/Kerbal Space Program</_KSPBT_SteamGameRoot>
5757
</PropertyGroup>
5858

59-
<!-- Import the csproj.user file. -->
60-
<!-- This can overwrite KSPBT_ManagedRelativePath and _KSPBT_GameExecutable,
61-
set KSPBT_GameRoot and ReferencePath, and any other user-specific settings -->
62-
<Import Project="$(MSBuildProjectFullPath).user" Condition="Exists('$(MSBuildProjectFullPath).user')"/>
63-
6459
<!-- Import a props.user file -->
6560
<!-- serves the same role as the csproj.user file -->
6661
<Import Condition=" Exists('$(SolutionDir)$(SolutionName).props.user') " Project="$(SolutionDir)$(SolutionName).props.user"/>
6762

6863
<!-- Import solution-wide props if it exists -->
6964
<Import Condition=" Exists('$(SolutionDir)$(SolutionName).props') " Project="$(SolutionDir)$(SolutionName).props"/>
7065

71-
<!-- Relative path that must exist for a path to be a valid KSP Install-->
72-
<PropertyGroup>
73-
<KSPBT_GameIdentifier>$(KSPBT_ManagedRelativePath)/Assembly-CSharp.dll</KSPBT_GameIdentifier>
74-
<KSPBT_GameRootSource Condition="'$(KSPBT_GameRoot)' != ''">property</KSPBT_GameRootSource>
75-
</PropertyGroup>
76-
77-
<!-- Default KSPBT_GameRoot to the "KSP_ROOT" environment variable if it exists -->
78-
<!-- Doing this skips any checks for a valid KSP install so be careful! -->
79-
<PropertyGroup Condition=" '$(KSPBT_GameRoot)' == '' And '$(KSP_ROOT)' != '' ">
80-
<KSPBT_GameRoot>$(KSP_ROOT)</KSPBT_GameRoot>
81-
<KSPBT_GameRootSource>environment variable</KSPBT_GameRootSource>
82-
</PropertyGroup>
83-
<ItemGroup>
84-
<KSPBT_GameRootCandidate Include="$(SolutionDir)KSP" source="solution directory"/>
85-
<KSPBT_GameRootCandidate Include="$(ReferencePath)" source="reference path"/>
86-
<KSPBT_GameRootCandidate Include="$(_KSPBT_SteamGameRoot)" source="steam"/>
87-
</ItemGroup>
88-
89-
<!-- Look for KSP install in Solution dir -->
90-
<PropertyGroup Condition=" '$(KSPBT_GameRoot)' == '' And Exists('$(SolutionDir)KSP/$(KSPBT_GameIdentifier)') ">
91-
<KSPBT_GameRoot>$(SolutionDir)KSP</KSPBT_GameRoot>
92-
<KSPBT_GameRootSource>solution directory</KSPBT_GameRootSource>
93-
</PropertyGroup>
94-
95-
<!-- Look for KSP install in ReferencePath -->
96-
<PropertyGroup Condition=" '$(KSPBT_GameRoot)' == '' And Exists('$(ReferencePath)/$(KSPBT_GameIdentifier)') ">
97-
<KSPBT_GameRoot>$(ReferencePath)</KSPBT_GameRoot>
98-
<KSPBT_GameRootSource>reference path</KSPBT_GameRootSource>
99-
</PropertyGroup>
100-
101-
<!-- Look for KSP steam install-->
102-
<PropertyGroup Condition=" '$(KSPBT_GameRoot)' == '' And Exists('$(_KSPBT_SteamGameRoot)/$(KSPBT_GameIdentifier)') ">
103-
<KSPBT_GameRoot>$(_KSPBT_SteamGameRoot)</KSPBT_GameRoot>
104-
<KSPBT_GameRootSource>steam</KSPBT_GameRootSource>
105-
</PropertyGroup>
106-
107-
<!-- set the start action so that you can launch directly from VS -->
108-
<PropertyGroup>
109-
<StartAction>Program</StartAction>
110-
<StartProgram>$(KSPBT_GameRoot)/$(_KSPBT_GameExecutable)</StartProgram>
111-
<StartWorkingDirectory>$(KSPBT_GameRoot)</StartWorkingDirectory>
112-
<DebugType>portable</DebugType>
113-
</PropertyGroup>
114-
11566
<ItemGroup>
11667
<Compile Include="$(MSBuildThisFileDirectory)/include/*.cs" Condition="exists('$(MSBuildThisFileDirectory)/include')"/>
11768
</ItemGroup>

KSPCommon.targets

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,51 @@
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Condition=" '$(KSPCommonPropsImported)' == '' And Exists('$(MSBuildThisFileDirectory)KSPCommon.props') " Project="$(MSBuildThisFileDirectory)KSPCommon.props"/>
44

5+
<!-- Relative path that must exist for a path to be a valid KSP Install-->
6+
<PropertyGroup>
7+
<KSPBT_GameIdentifier>$(KSPBT_ManagedRelativePath)/Assembly-CSharp.dll</KSPBT_GameIdentifier>
8+
<KSPBT_GameRootSource Condition="'$(KSPBT_GameRoot)' != ''">property</KSPBT_GameRootSource>
9+
</PropertyGroup>
10+
11+
<!-- Default KSPBT_GameRoot to the "KSP_ROOT" environment variable if it exists -->
12+
<!-- Doing this skips any checks for a valid KSP install so be careful! -->
13+
<PropertyGroup Condition=" '$(KSPBT_GameRoot)' == '' And '$(KSP_ROOT)' != '' ">
14+
<KSPBT_GameRoot>$(KSP_ROOT)</KSPBT_GameRoot>
15+
<KSPBT_GameRootSource>environment variable</KSPBT_GameRootSource>
16+
</PropertyGroup>
17+
<ItemGroup>
18+
<KSPBT_GameRootCandidate Include="$(SolutionDir)KSP" source="solution directory"/>
19+
<KSPBT_GameRootCandidate Include="$(ReferencePath)" source="reference path"/>
20+
<KSPBT_GameRootCandidate Include="$(_KSPBT_SteamGameRoot)" source="steam"/>
21+
</ItemGroup>
22+
23+
<!-- Look for KSP install in Solution dir -->
24+
<PropertyGroup Condition=" '$(KSPBT_GameRoot)' == '' And Exists('$(SolutionDir)KSP/$(KSPBT_GameIdentifier)') ">
25+
<KSPBT_GameRoot>$(SolutionDir)KSP</KSPBT_GameRoot>
26+
<KSPBT_GameRootSource>solution directory</KSPBT_GameRootSource>
27+
</PropertyGroup>
28+
29+
<!-- Look for KSP install in ReferencePath -->
30+
<PropertyGroup Condition=" '$(KSPBT_GameRoot)' == '' And Exists('$(ReferencePath)/$(KSPBT_GameIdentifier)') ">
31+
<KSPBT_GameRoot>$(ReferencePath)</KSPBT_GameRoot>
32+
<KSPBT_GameRootSource>reference path</KSPBT_GameRootSource>
33+
</PropertyGroup>
34+
35+
<!-- Look for KSP steam install-->
36+
<PropertyGroup Condition=" '$(KSPBT_GameRoot)' == '' And Exists('$(_KSPBT_SteamGameRoot)/$(KSPBT_GameIdentifier)') ">
37+
<KSPBT_GameRoot>$(_KSPBT_SteamGameRoot)</KSPBT_GameRoot>
38+
<KSPBT_GameRootSource>steam</KSPBT_GameRootSource>
39+
</PropertyGroup>
40+
41+
<!-- set the start action so that you can launch directly from VS -->
42+
<PropertyGroup>
43+
<StartAction>Program</StartAction>
44+
<StartProgram>$(KSPBT_GameRoot)/$(_KSPBT_GameExecutable)</StartProgram>
45+
<StartWorkingDirectory>$(KSPBT_GameRoot)</StartWorkingDirectory>
46+
<DebugType>portable</DebugType>
47+
</PropertyGroup>
48+
49+
550
<!-- Calculate KSPBT_ManagedPath -->
651
<PropertyGroup Condition=" '$(KSPBT_ManagedPath)' == ''">
752
<KSPBT_ManagedPath>$(KSPBT_GameRoot)/$(KSPBT_ManagedRelativePath)</KSPBT_ManagedPath>

0 commit comments

Comments
 (0)