summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-07-09 23:29:51 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-07-09 23:29:51 -0400
commitcf6445b8e1cfac6299102582288f5406daa724a5 (patch)
tree0998802b0c8a5abdb44a48adaaa6715548ecc57d /build
parent088d4e77f0e012e921543998bf121c0b4db95a4a (diff)
downloadSMAPI-cf6445b8e1cfac6299102582288f5406daa724a5.tar.gz
SMAPI-cf6445b8e1cfac6299102582288f5406daa724a5.tar.bz2
SMAPI-cf6445b8e1cfac6299102582288f5406daa724a5.zip
improve OS and game path detection to avoid crossplatform issues
Diffstat (limited to 'build')
-rw-r--r--build/smapi.targets58
1 files changed, 31 insertions, 27 deletions
diff --git a/build/smapi.targets b/build/smapi.targets
index ea6af723..e2af5d90 100644
--- a/build/smapi.targets
+++ b/build/smapi.targets
@@ -6,35 +6,36 @@
<Import Condition="$(OS) == 'Windows_NT' AND Exists('$(USERPROFILE)\stardewvalley.targets')" Project="$(USERPROFILE)\stardewvalley.targets" />
<!--######
- ## select target OS
+ ## find platform + game path
#######-->
- <PropertyGroup>
- <GamePlatform Condition="$(OS) == 'Unix'">Linux</GamePlatform>
- <GamePlatform Condition="$(OS) == 'OSX'">Mac</GamePlatform>
- <GamePlatform Condition="$(OS) == 'Windows_NT'">Windows</GamePlatform>
- </PropertyGroup>
-
- <!--######
- ## select game path
- #######-->
- <PropertyGroup>
- <!-- Linux -->
- <GamePath Condition="!Exists('$(GamePath)')">$(HOME)/GOG Games/Stardew Valley/game</GamePath>
- <GamePath Condition="!Exists('$(GamePath)')">$(HOME)/.local/share/Steam/steamapps/common/Stardew Valley</GamePath>
-
- <!-- Mac -->
- <GamePath Condition="!Exists('$(GamePath)')">/Applications/Stardew Valley.app/Contents/MacOS</GamePath>
- <GamePath Condition="!Exists('$(GamePath)')">$(HOME)/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS</GamePath>
-
- <!-- Windows -->
- <GamePath Condition="!Exists('$(GamePath)')">C:\Program Files (x86)\GalaxyClient\Games\Stardew Valley</GamePath>
- <GamePath Condition="!Exists('$(GamePath)')">C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley</GamePath>
- <GamePath Condition="!Exists('$(GamePath)') AND '$(GamePlatform)' == 'Windows'">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\GOG.com\Games\1453375253', 'PATH', null, RegistryView.Registry32))</GamePath>
- <GamePath Condition="!Exists('$(GamePath)') AND '$(GamePlatform)' == 'Windows'">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 413150', 'InstallLocation', null, RegistryView.Registry64, RegistryView.Registry32))</GamePath>
- </PropertyGroup>
+ <Choose>
+ <When Condition="$(OS) == 'Unix'">
+ <PropertyGroup>
+ <GamePlatform>Linux</GamePlatform>
+ <GamePath Condition="!Exists('$(GamePath)')">$(HOME)/GOG Games/Stardew Valley/game</GamePath>
+ <GamePath Condition="!Exists('$(GamePath)')">$(HOME)/.local/share/Steam/steamapps/common/Stardew Valley</GamePath>
+ </PropertyGroup>
+ </When>
+ <When Condition="$(OS) == 'OSX'">
+ <PropertyGroup>
+ <GamePlatform>Mac</GamePlatform>
+ <GamePath Condition="!Exists('$(GamePath)')">/Applications/Stardew Valley.app/Contents/MacOS</GamePath>
+ <GamePath Condition="!Exists('$(GamePath)')">$(HOME)/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS</GamePath>
+ </PropertyGroup>
+ </When>
+ <When Condition="$(OS) == 'Windows_NT'">
+ <PropertyGroup>
+ <GamePlatform>Windows</GamePlatform>
+ <GamePath Condition="!Exists('$(GamePath)')">C:\Program Files (x86)\GalaxyClient\Games\Stardew Valley</GamePath>
+ <GamePath Condition="!Exists('$(GamePath)')">C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley</GamePath>
+ <GamePath Condition="!Exists('$(GamePath)')">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\GOG.com\Games\1453375253', 'PATH', null, RegistryView.Registry32))</GamePath>
+ <GamePath Condition="!Exists('$(GamePath)')">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 413150', 'InstallLocation', null, RegistryView.Registry64, RegistryView.Registry32))</GamePath>
+ </PropertyGroup>
+ </When>
+ </Choose>
<!--######
- ## set up configuration
+ ## configure build
#######-->
<Choose>
<When Condition="$(GamePlatform) == 'Windows'">
@@ -99,6 +100,9 @@
## validate
#######-->
<Target Name="BeforeBuild">
+ <!-- show error for unknown platform -->
+ <Error Condition="'$(GamePlatform)' != 'Linux' AND '$(GamePlatform)' != 'Mac' AND '$(GamePlatform)' != 'Windows'" Text="The build config package doesn't recognise OS type '$(OS)' (mapped to game platform '$(GamePlatform)')." />
+
<!-- if game path is invalid, show one user-friendly error instead of a slew of reference errors -->
<Error Condition="!Exists('$(GamePath)')" Text="Failed to find the game install path. See https://github.com/Pathoschild/Stardew.ModBuildConfig#troubleshoot for help." />
<Error Condition="'$(GamePlatform)' == 'Windows' AND !Exists('$(GamePath)\Stardew Valley.exe')" Text="Found a game folder at $(GamePath), but it doesn't contain Stardew Valley. You should delete this folder if it's empty." />
@@ -107,7 +111,7 @@
</Target>
<!--######
- ## deploy mod files
+ ## deploy mod files on build
#######-->
<Target Name="AfterBuild" Condition="'$(DeployModFolderName)' != ''">
<!--generate paths-->