Skip to content

Commit 29bd96d

Browse files
authored
Merge pull request #109 from patchkit-net/feature/v3.11.x/1115-osx-executable-args-issue
Feature/v3.11.x/1115 osx executable args issue
2 parents 6ec84b7 + 55b1249 commit 29bd96d

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

Assets/PatchKit Patcher/Scripts/AppStarter.cs

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,17 @@ public AppStarter(App app)
2929

3030
private string ResolveExecutablePath(AppVersion appVersion)
3131
{
32+
PlatformType platformType = Platform.GetPlatformType();
33+
3234
if (!string.IsNullOrEmpty(appVersion.MainExecutable))
3335
{
3436
string executablePath = Path.Combine(_app.LocalDirectory.Path, appVersion.MainExecutable);
3537

36-
if (File.Exists(executablePath))
38+
bool isOSXApp = platformType == PlatformType.OSX &&
39+
executablePath.EndsWith(".app") &&
40+
Directory.Exists(executablePath);
41+
42+
if (File.Exists(executablePath) || isOSXApp)
3743
{
3844
return executablePath;
3945
}
@@ -50,7 +56,6 @@ private string ResolveExecutablePath(AppVersion appVersion)
5056

5157
}
5258

53-
PlatformType platformType = Platform.GetPlatformType();
5459
return AppFinder.FindExecutable(_app.LocalDirectory.Path, platformType);
5560
}
5661

@@ -87,12 +92,7 @@ private void StartAppVersion(AppVersion appVersion)
8792
}
8893
}
8994

90-
var processStartInfo = GetProcessStartInfo(appFilePath, platformType);
91-
92-
if (!string.IsNullOrEmpty(appVersion.MainExecutableArgs))
93-
{
94-
processStartInfo.Arguments += " " + appVersion.MainExecutableArgs;
95-
}
95+
var processStartInfo = GetProcessStartInfo(appFilePath, appVersion.MainExecutableArgs, platformType);
9696

9797
StartAppProcess(processStartInfo);
9898
}
@@ -102,8 +102,13 @@ private bool NeedPermissionFix(PlatformType platformType)
102102
return platformType == PlatformType.OSX || platformType == PlatformType.Linux;
103103
}
104104

105-
private ProcessStartInfo GetProcessStartInfo(string executablePath, PlatformType platform)
105+
private ProcessStartInfo GetProcessStartInfo(string executablePath, string mainExecutableArgs, PlatformType platform)
106106
{
107+
if (mainExecutableArgs == null)
108+
{
109+
mainExecutableArgs = string.Empty;
110+
}
111+
107112
string workingDir = Path.GetDirectoryName(executablePath) ?? string.Empty;
108113
switch (platform)
109114
{
@@ -113,20 +118,26 @@ private ProcessStartInfo GetProcessStartInfo(string executablePath, PlatformType
113118
return new ProcessStartInfo
114119
{
115120
FileName = executablePath,
116-
Arguments = string.Format("+patcher-data-location \"{0}\"", _app.LocalMetaData.GetFilePath()),
121+
Arguments = string.Format("+patcher-data-location \"{0}\" " + mainExecutableArgs, _app.LocalMetaData.GetFilePath()),
117122
WorkingDirectory = workingDir
118123
};
119124
case PlatformType.OSX:
125+
if (!string.IsNullOrEmpty(mainExecutableArgs))
126+
{
127+
mainExecutableArgs = " --args " + mainExecutableArgs;
128+
}
129+
120130
return new ProcessStartInfo
121131
{
122132
FileName = "open",
123-
Arguments = string.Format("\"{0}\"", executablePath),
133+
Arguments = string.Format("\"{0}\"{1}", executablePath, mainExecutableArgs),
124134
WorkingDirectory = workingDir
125135
};
126136
case PlatformType.Linux:
127137
return new ProcessStartInfo
128138
{
129139
FileName = executablePath,
140+
Arguments = mainExecutableArgs,
130141
WorkingDirectory = workingDir
131142
};
132143
default:

0 commit comments

Comments
 (0)