-
Notifications
You must be signed in to change notification settings - Fork 27
添加了代理命令(包装命令) #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
添加了代理命令(包装命令) #173
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -377,11 +377,19 @@ public override async Task<LaunchResult> LaunchTaskAsync(LaunchSettings settings | |
| ? Path.Combine(this.RootPath, GamePathHelper.GetGamePath(settings.Version)) | ||
| : this.RootPath; | ||
|
|
||
| ProcessStartInfo psi; | ||
| ProcessStartInfo processStartInfo; | ||
|
|
||
| var commandProxy = settings.CommandProxy; | ||
|
|
||
| if (!settings.UseShellExecute) | ||
| { | ||
| psi = new ProcessStartInfo(java!.JavaPath, string.Join(' ', arguments)) | ||
| var (command, finalArguments) = string.IsNullOrWhiteSpace(commandProxy) switch | ||
| { | ||
| true => (java!.JavaPath, string.Join(' ', arguments)), | ||
| false => (commandProxy.Trim(), $"\"{java!.JavaPath}\" {string.Join(' ', arguments)}") | ||
| }; | ||
|
|
||
| processStartInfo = new ProcessStartInfo(command, finalArguments) | ||
| { | ||
| UseShellExecute = false, | ||
| WorkingDirectory = rootPath, | ||
|
|
@@ -394,9 +402,11 @@ public override async Task<LaunchResult> LaunchTaskAsync(LaunchSettings settings | |
| else | ||
| { | ||
| var normalJavaPath = java!.JavaPath.Replace("javaw", "java", StringComparison.OrdinalIgnoreCase); | ||
| var javaCommand = $"\"{normalJavaPath}\" {string.Join(' ', arguments)}"; | ||
| var javaCommand = string.IsNullOrWhiteSpace(commandProxy) | ||
| ? $"\"{normalJavaPath}\" {string.Join(' ', arguments)}" | ||
| : $"\"{commandProxy}\" \"{normalJavaPath}\" {string.Join(' ', arguments)}"; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps we shouldn't use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By the way, what about to use a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 阿巴阿巴()好像说太多了()木有为难的意思,现在这样也可以()我先approve了()
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
我想的是,如果用的是/path to/file这样的格式,应该考虑双引号封一起,不然路径有问题。至于dotnet run这种就不太好处理,这个要用dotnet作为程序主体吧,然后run 其他参数。其实也可以是分成代理命令主体和代理命令参数两个部分。但是这样要是用ls | grep 之类的管道符就很复杂了吧。一般就用一个prime-run,问题应该不大
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
或许是可行的办法,在useShellExecute的时候通过,在不使用的情况下需要确定命令的主体 |
||
|
|
||
| psi = javaCommand switch | ||
| processStartInfo = javaCommand switch | ||
| { | ||
| _ when RuntimeInformation.IsOSPlatform(OSPlatform.Windows) => | ||
| await StartGameInShellInWindows(rootPath, javaCommand), | ||
|
|
@@ -406,15 +416,15 @@ await StartGameInShellInUnix(rootPath, javaCommand), | |
| _ => throw new PlatformNotSupportedException("Unsupported OS platform.") | ||
| }; | ||
| } | ||
|
|
||
| if (!settings.UseShellExecute) | ||
| { | ||
| // Patch for third-party launcher | ||
| psi.EnvironmentVariables.Remove("JAVA_TOOL_OPTIONS"); | ||
| processStartInfo.EnvironmentVariables.Remove("JAVA_TOOL_OPTIONS"); | ||
|
|
||
| foreach (var (k, v) in ParseGameEnv(settings.GameEnvironmentVariables)) | ||
| { | ||
| psi.EnvironmentVariables.Add(k, v); | ||
| processStartInfo.EnvironmentVariables.Add(k, v); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -451,7 +461,7 @@ await Task.Run(() => | |
| var launchWrapper = new LaunchWrapper(authResult, settings) | ||
| { | ||
| GameCore = this, | ||
| Process = Process.Start(psi) | ||
| Process = Process.Start(processStartInfo) | ||
| }; | ||
|
|
||
| launchWrapper.Do(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to this pr but @laolarou726 what's this? what if the path is "myjavawow/javaw.exe"? as a launcher core i think we should exactly use the given path. the problem that users might accidently select javaw should be addressed by the user inferface part.