diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ManagedEntrance.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ManagedEntrance.cs
index c1b283e68..5f516948c 100644
--- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ManagedEntrance.cs
+++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ManagedEntrance.cs
@@ -26,9 +26,7 @@ namespace Microsoft.PowerShell
///
/// Command line arguments to the managed MSH
///
-#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
{
diff --git a/src/powershell/Program.cs b/src/powershell/Program.cs
new file mode 100644
index 000000000..eea047769
--- /dev/null
+++ b/src/powershell/Program.cs
@@ -0,0 +1,29 @@
+/********************************************************************++
+Copyright (c) Microsoft Corporation. All rights reserved.
+--********************************************************************/
+
+using System.Management.Automation;
+
+namespace Microsoft.PowerShell
+{
+ ///
+ /// Defines an entry point for the .NET CLI "powershell" app
+ ///
+ public sealed class ManagedPSEntry
+ {
+ ///
+ /// Starts the managed MSH
+ ///
+ ///
+ /// Command line arguments to the managed MSH
+ ///
+ public static int Main(string[] args)
+ {
+#if CORECLR
+ // Open PowerShell has to set the ALC here, since we don't own the native host
+ PowerShellAssemblyLoadContextInitializer.SetPowerShellAssemblyLoadContext(string.Empty);
+#endif
+ return UnmanagedPSEntry.Start(string.Empty, args, args.Length);
+ }
+ }
+}