2016-05-09 14:41:44 -07:00
|
|
|
/********************************************************************++
|
|
|
|
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
|
--********************************************************************/
|
|
|
|
|
|
2016-06-28 09:59:22 -07:00
|
|
|
using System;
|
2016-05-09 14:41:44 -07:00
|
|
|
using System.Management.Automation;
|
2016-06-24 16:25:49 -07:00
|
|
|
using System.Reflection;
|
2016-05-09 14:41:44 -07:00
|
|
|
|
|
|
|
|
namespace Microsoft.PowerShell
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Defines an entry point for the .NET CLI "powershell" app
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed class ManagedPSEntry
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Starts the managed MSH
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="args">
|
|
|
|
|
/// Command line arguments to the managed MSH
|
|
|
|
|
/// </param>
|
|
|
|
|
public static int Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
#if CORECLR
|
2016-08-16 17:03:34 -07:00
|
|
|
// PowerShell has to set the ALC here, since we don't own the native host
|
2016-06-28 09:59:22 -07:00
|
|
|
string appBase = System.IO.Path.GetDirectoryName(typeof(ManagedPSEntry).GetTypeInfo().Assembly.Location);
|
|
|
|
|
return (int)PowerShellAssemblyLoadContextInitializer.
|
|
|
|
|
InitializeAndCallEntryMethod(
|
|
|
|
|
appBase,
|
|
|
|
|
new AssemblyName("Microsoft.PowerShell.ConsoleHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"),
|
|
|
|
|
"Microsoft.PowerShell.UnmanagedPSEntry",
|
|
|
|
|
"Start",
|
|
|
|
|
new object[] { string.Empty, args, args.Length });
|
2016-06-24 16:25:49 -07:00
|
|
|
#else
|
2016-05-09 14:41:44 -07:00
|
|
|
return UnmanagedPSEntry.Start(string.Empty, args, args.Length);
|
2016-06-24 16:25:49 -07:00
|
|
|
#endif
|
2016-05-09 14:41:44 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|