From d5f5645f4d11e960a9d16cc00cbdf5c9bbda975f Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Wed, 23 Dec 2015 16:45:54 -0800 Subject: [PATCH] Eliminate dependency on native host for shell PSRP will of course still require it, but now the managed host sets up the assembly load context, meaning we can depend on the emitted binary from dotnet-cli. --- debug.sh | 3 +-- pester.sh | 3 +-- powershell | 1 - run.sh | 3 +-- src/Microsoft.PowerShell.Linux.Host/main.cs | 6 ++++++ 5 files changed, 9 insertions(+), 7 deletions(-) delete mode 120000 powershell diff --git a/debug.sh b/debug.sh index 57b09b66c8..6699d0dbdd 100755 --- a/debug.sh +++ b/debug.sh @@ -1,2 +1 @@ -export CORE_ROOT=$(pwd)/bin -lldb-3.6 -o "plugin load ./bin/libsosplugin.so" -- ./powershell $@ +lldb-3.6 -o "plugin load ./bin/libsosplugin.so" -- ./bin/Microsoft.PowerShell.Linux.Host $@ diff --git a/pester.sh b/pester.sh index 6e7102f388..78db7d2daa 100755 --- a/pester.sh +++ b/pester.sh @@ -1,5 +1,4 @@ -export CORE_ROOT=$(pwd)/bin -./powershell -c "Invoke-Pester src/pester-tests/$1 -OutputFile pester-tests.xml -OutputFormat NUnitXml" +./bin/Microsoft.PowerShell.Linux.Host -c "Invoke-Pester src/pester-tests/$1 -OutputFile pester-tests.xml -OutputFormat NUnitXml" # XML files are not executable chmod -x pester-tests.xml # Fix tty due to possible bug in .NET diff --git a/powershell b/powershell deleted file mode 120000 index 3efba138a3..0000000000 --- a/powershell +++ /dev/null @@ -1 +0,0 @@ -src/monad-native/host/powershell \ No newline at end of file diff --git a/run.sh b/run.sh index 597a39195b..05ac417c29 100755 --- a/run.sh +++ b/run.sh @@ -1,4 +1,3 @@ -export CORE_ROOT=$(pwd)/bin -./powershell $@ +./bin/Microsoft.PowerShell.Linux.Host $@ # Fix tty due to possible bug in .NET stty echo diff --git a/src/Microsoft.PowerShell.Linux.Host/main.cs b/src/Microsoft.PowerShell.Linux.Host/main.cs index e79a0ccc48..77a56ac777 100644 --- a/src/Microsoft.PowerShell.Linux.Host/main.cs +++ b/src/Microsoft.PowerShell.Linux.Host/main.cs @@ -18,6 +18,12 @@ namespace Microsoft.PowerShell.Linux.Host /// public static void Main(string[] args) { + // Setup the Assembly Load Context, which Core PowerShell uses to + // analyze the libraries for types, functions, cmdlets, etc. and + // provide the ability to load assemblies by file path. Doing this + // here eliminates the need for a custom native host. + PowerShellAssemblyLoadContextInitializer.SetPowerShellAssemblyLoadContext(AppContext.BaseDirectory); + // Custom argument parsing string initialScript = null; if (args.Length > 0)