mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
Add managed entrance for powershell project
The powershell project's `Main` function initializes the custom `AssemblyLoadContext` and then delegates to `UnmanagedPSEntry.Start`. This lets us undo several changes to the `ConsoleHost` managed entry (notably, the `Start` function signature does not have to change, thus the `consoleFilePath` variable still exists).
This commit is contained in:
1 parent
a1a722c4a1
commit
630eb69c7c
2 files changed
+30
-10
No files matched your search
@@ -26,9 +26,7 @@ namespace Microsoft.PowerShell
|
||||
/// <param name="args">
|
||||
/// Command line arguments to the managed MSH
|
||||
/// </param>
|
||||
#if OPEN && CORECLR // Open PowerShell needs an actual Main entry-point
|
||||
public static int Main(string[] args)
|
||||
#elif CORECLR
|
||||
#if CORECLR
|
||||
#pragma warning disable 1573
|
||||
public static int Start(string consoleFilePath, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 2)]string[] args, int argc)
|
||||
#pragma warning restore 1573
|
||||
@@ -36,9 +34,6 @@ namespace Microsoft.PowerShell
|
||||
public int Start(string consoleFilePath, string[] args)
|
||||
#endif
|
||||
{
|
||||
#if OPEN && CORECLR // Open PowerShell has to set the ALC here, since we don't own the native host
|
||||
PowerShellAssemblyLoadContextInitializer.SetPowerShellAssemblyLoadContext(string.Empty);
|
||||
#endif
|
||||
System.Management.Automation.Runspaces.EarlyStartup.Init();
|
||||
|
||||
// Set ETW activity Id
|
||||
@@ -74,9 +69,7 @@ namespace Microsoft.PowerShell
|
||||
// PSSnapInException will cause the control to return back to the native code
|
||||
// and stuff the EXCEPINFO field with the message of the exception.
|
||||
// The native code will print this out and exit the process.
|
||||
#if !OPEN // consoleFilePath is not available in Open PowerShell
|
||||
if (string.IsNullOrEmpty(consoleFilePath))
|
||||
#endif
|
||||
{
|
||||
#if DEBUG
|
||||
// Special switches for debug mode to allow self-hosting on InitialSessionState instead
|
||||
@@ -103,14 +96,12 @@ namespace Microsoft.PowerShell
|
||||
configuration = null;
|
||||
#endif
|
||||
}
|
||||
#if !OPEN // consoleFilePath is not available in Open PowerShell
|
||||
else
|
||||
{
|
||||
//TODO : Deprecate RunspaceConfiguration and use InitialSessionState
|
||||
configuration =
|
||||
RunspaceConfigForSingleShell.Create(consoleFilePath, out warning);
|
||||
}
|
||||
#endif
|
||||
int exitCode = 0;
|
||||
try
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user