Skip to content

Commit

Permalink
Stupid MSBuild limitations
Browse files Browse the repository at this point in the history
  • Loading branch information
drewcassidy committed Sep 22, 2024
1 parent 75a60e1 commit 9421eca
Showing 1 changed file with 16 additions and 34 deletions.
50 changes: 16 additions & 34 deletions KSPCommon.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
<KSPCommonPropsImported>true</KSPCommonPropsImported>
</PropertyGroup>

<!-- default CKAN compatibility versions -->
<PropertyGroup>
<CKANCompatibleVersions Condition="('$(CKANCompatibleVersions)' == '')">1.12 1.11 1.10 1.9 1.8</CKANCompatibleVersions>
</PropertyGroup>

<!--Parse KSP platform-specific paths -->
<!-- These can be overwritten by user and props files -->
<PropertyGroup Condition=" '$(ManagedRelativePath)' == '' ">
Expand Down Expand Up @@ -40,46 +45,23 @@
<Import Condition=" Exists('$(SolutionDir)$(SolutionName).props') " Project="$(SolutionDir)$(SolutionName).props"/>

<PropertyGroup>
<!-- Default KSPRoot to the "KSP_ROOT" environment variable if it exists -->
<!-- Doing this overrides any checks for a valid KSP install so be careful! -->
<KSPRoot Condition=" '$(KSPRoot)' == '' And '$(KSP_ROOT)' != ''">$(KSP_ROOT)</KSPRoot>
</PropertyGroup>
<!-- Relative path that must exist for a path to be a valid KSP Install-->
<KSPRootIdentifier>$(ManagedRelativePath)/Assembly-CSharp.dll</KSPRootIdentifier>

<!-- Search for KSPRoot -->
<PropertyGroup>
<!-- Default KSPRoot to the "KSP_ROOT" environment variable if it exists -->
<!-- Doing this overrides any checks for a valid KSP install so be careful! -->
<KSPRoot Condition=" '$(KSPRoot)' == '' And '$(KSP_ROOT)' != ''">$(KSP_ROOT)</KSPRoot>

<!-- look for a KSP installation in SolutionDir -->
<KSPRoot Condition=" '$(KSPRoot)' == '' And Exists('$(SolutionDir)KSP/GameData')">$(SolutionDir)KSP</KSPRoot>

<!-- use ReferencePath if it exists and is a valid KSP install -->
<KSPRoot Condition=" '$(KSPRoot)' == '' And Exists('$(ReferencePath)GameData')">$(ReferencePath.TrimEnd([System.IO.Path]::DirectorySeparatorChar))</KSPRoot>
<!-- Doing this skips any checks for a valid KSP install so be careful! -->
<KSPRoot Condition=" '$(KSPRoot)' == '' And '$(KSP_ROOT)' != '' ">$(KSP_ROOT)</KSPRoot>

<!--If the reference path isn't set, use the default steam location, but this will be incorrect in lots of cases-->
<KSPRoot Condition="'$(KSPRoot)' == '' And Exists('$(SteamKSPRoot)/GameData')">$(SteamKSPRoot)</KSPRoot>
<!-- Look for KSP install in Solution dir -->
<KSPRoot Condition=" '$(KSPRoot)' == '' And Exists('$(SolutionDir)KSP/$(KSPRootIdentifier)') ">$(SolutionDir)KSP</KSPRoot>

<!-- default CKAN compatibility versions -->
<CKANCompatibleVersions Condition="('$(CKANCompatibleVersions)' == '')">1.12 1.11 1.10 1.9 1.8</CKANCompatibleVersions>
</PropertyGroup>
<!-- Look for KSP install in ReferencePath -->
<KSPRoot Condition=" '$(KSPRoot)' == '' And Exists('$(ReferencePath)/$(KSPRootIdentifier)') ">$(ReferencePath)</KSPRoot>

<!-- Assemble a list of KSPRoot candidates. Additional items can be defined in .csproj.user if desired -->
<ItemGroup>
<KSPRootCandidate Include="$(SolutionDir)KSP"/>
<KSPRootCandidate Include="$(ReferencePath)"/>
<KSPRootCandidate Include="$(SteamKSPRoot)"/>
</ItemGroup>
<!-- Search through candidates and select the first one that looks like a valid install-->
<ItemGroup>
<_ValidKSPRootCandidate Include="@(KSPRootCandidate.Identity)" Condition="Exists('@(KSPRootCandidate.Identity)/$(ManagedRelativePath/Assembly-CSharp.dll')"/>
</ItemGroup>
<PropertyGroup>
<KSPRoot Condition="'$(KSPRoot)' == '' "> %(_ValidKSPRootCandidate.Identity) </KSPRoot>
</PropertyGroup>
<!-- Look for KSP steam install-->
<KSPRoot Condition=" '$(KSPRoot)' == '' And Exists('$(SteamKSPRoot)/$(KSPRootIdentifier)') ">$(SteamKSPRoot)</KSPRoot>

<!-- Calculate ManagedPath -->
<PropertyGroup>
<!-- Calculate ManagedPath -->
<ManagedPath>$(KSPRoot)/$(ManagedRelativePath)</ManagedPath>
</PropertyGroup>

Expand Down

0 comments on commit 9421eca

Please sign in to comment.