-
-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build as Self Contained and Selfhost CefSharp SubProcess (#693)
* Added self contained parameter to builds * Remove dotnet install from installer * Fixed missing SubProcessExe * Self hot browser subprocess --------- Co-authored-by: Natsumi <cmcooper123@hotmail.com>
- Loading branch information
1 parent
312519b
commit f053f2b
Showing
7 changed files
with
61 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using CefSharp.Internals; | ||
using System; | ||
using System.IO; | ||
|
||
namespace VRCX; | ||
|
||
public class BrowserSubprocess | ||
{ | ||
/// <summary> | ||
/// This function should be called from the application entry point function (typically Program.Main) | ||
/// to execute a secondary process e.g. gpu, renderer, utility | ||
/// This overload is specifically used for .Net Core. For hosting your own BrowserSubProcess | ||
/// it's preferable to use the Main method provided by this class. | ||
/// - Pass in command line args | ||
/// </summary> | ||
/// <param name="args">command line args</param> | ||
/// <returns> | ||
/// If called for the browser process (identified by no "type" command-line value) it will return immediately | ||
/// with a value of -1. If called for a recognized secondary process it will block until the process should exit | ||
/// and then return the process exit code. | ||
/// </returns> | ||
public static void Start() | ||
{ | ||
var args = Environment.GetCommandLineArgs(); | ||
var type = CommandLineArgsParser.GetArgumentValue(args, CefSharpArguments.SubProcessTypeArgument); | ||
|
||
if (string.IsNullOrEmpty(type)) | ||
{ | ||
// If --type param missing from command line CEF/Chromium assums | ||
// this is the main process (as all subprocesses must have a type param). | ||
return; | ||
} | ||
|
||
var browserSubprocessDllPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "CefSharp.BrowserSubprocess.Core.dll"); | ||
if (!File.Exists(browserSubprocessDllPath)) | ||
{ | ||
browserSubprocessDllPath = Path.Combine(Path.GetDirectoryName(typeof(CefSharp.Core.BrowserSettings).Assembly.Location), "CefSharp.BrowserSubprocess.Core.dll"); | ||
} | ||
var browserSubprocessDll = System.Runtime.Loader.AssemblyLoadContext.Default.LoadFromAssemblyPath(browserSubprocessDllPath); | ||
var browserSubprocessExecutableType = browserSubprocessDll.GetType("CefSharp.BrowserSubprocess.BrowserSubprocessExecutable"); | ||
|
||
var browserSubprocessExecutable = Activator.CreateInstance(browserSubprocessExecutableType); | ||
|
||
var mainMethod = browserSubprocessExecutableType.GetMethod("MainSelfHost", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public); | ||
var argCount = mainMethod.GetParameters(); | ||
|
||
var methodArgs = new object[] { args }; | ||
|
||
var exitCode = mainMethod.Invoke(null, methodArgs); | ||
|
||
Environment.Exit((int)exitCode); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
@echo off | ||
dotnet build VRCX.sln -p:Configuration=Release -p:Platform=x64 -p:RestorePackagesConfig=true -t:"Restore;Clean;Build" -m | ||
dotnet build VRCX.sln -p:Configuration=Release -p:Platform=x64 -p:RestorePackagesConfig=true -t:"Restore;Clean;Build" -m --self-contained | ||
mklink /J "%~dp0\bin\x64\Release\html" "%~dp0\html\dist" | ||
pause |