@@ -26,6 +26,11 @@ public class BuildPostprocessing : IPostprocessBuildWithReport
26
26
27
27
private static readonly Logger Logger = LogManager . GetCurrentClassLogger ( ) ;
28
28
29
+ private const string _unsupportedPlaformMessage =
30
+ "Visual Pinball Engine does not ship with an MPF executable for the build "
31
+ + "platform '{}}.' The build will not work unless MPF is installed "
32
+ + "on the end-user's device" ;
33
+
29
34
void IPostprocessBuildWithReport . OnPostprocessBuild ( BuildReport report )
30
35
{
31
36
if (
@@ -34,16 +39,39 @@ void IPostprocessBuildWithReport.OnPostprocessBuild(BuildReport report)
34
39
)
35
40
return ;
36
41
37
- var streamingAssetsPath = FindStreamingAssets ( report . summary . outputPath ) ;
42
+ var streamingAssetsPath = FindStreamingAssets (
43
+ report . summary . platform ,
44
+ report . summary . outputPath
45
+ ) ;
38
46
CleanMachineFolder ( streamingAssetsPath ) ;
39
47
AddMpfBinaries ( report . summary . platform , streamingAssetsPath ) ;
40
48
}
41
49
42
- private static string FindStreamingAssets ( string buildExePath )
50
+ private static string FindStreamingAssets ( BuildTarget platform , string buildExePath )
43
51
{
44
- var dataDir = Directory
45
- . GetDirectories ( Directory . GetParent ( buildExePath ) . ToString ( ) , "*_Data" )
46
- . FirstOrDefault ( ) ;
52
+ string dataDir ;
53
+
54
+ if (
55
+ platform
56
+ is BuildTarget . StandaloneWindows
57
+ or BuildTarget . StandaloneWindows64
58
+ or BuildTarget . StandaloneLinux64
59
+ )
60
+ {
61
+ dataDir = Directory
62
+ . GetDirectories ( Directory . GetParent ( buildExePath ) . ToString ( ) , "*_Data" )
63
+ . FirstOrDefault ( ) ;
64
+ }
65
+ else if ( platform is BuildTarget . StandaloneOSX )
66
+ {
67
+ dataDir = Path . Combine ( buildExePath , "Contents" , "Resources" , "Data" ) ;
68
+ }
69
+ else
70
+ {
71
+ throw new PlatformNotSupportedException (
72
+ string . Format ( _unsupportedPlaformMessage , platform )
73
+ ) ;
74
+ }
47
75
48
76
return Path . Combine ( dataDir , "StreamingAssets" ) ;
49
77
}
@@ -63,9 +91,7 @@ private static void AddMpfBinaries(BuildTarget platform, string streamingAssetsP
63
91
BuildTarget . StandaloneWindows => Constants . MpfBinaryDirWindows ,
64
92
BuildTarget . StandaloneWindows64 => Constants . MpfBinaryDirWindows ,
65
93
_ => throw new PlatformNotSupportedException (
66
- "Visual Pinball Engine does not ship with an MPF executable for the build "
67
- + $ "platform '{ platform } .' The build will not work unless MPF is installed "
68
- + $ "on the end-user's device"
94
+ string . Format ( _unsupportedPlaformMessage , platform )
69
95
) ,
70
96
} ;
71
97
var sourcePath = Path . Combine (
0 commit comments