diff --git a/scripts/Makefile b/scripts/Makefile index a4f74c315c..b55d818901 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -116,8 +116,8 @@ libps-build/Makefile: ../src/monad-native/src/CMakeLists.txt rm -f ../src/monad-native/src/cmake_install.cmake cd libps-build && cmake ../../src/monad-native/src/ -dotnetlibs/libps.so dotnetlibs/monad_native: libps-build/Makefile - cd libps-build && make VERBOSE=0 && cp monad_native ../dotnetlibs && cp libps.so ../dotnetlibs +dotnetlibs/libps.so dotnetlibs/monad_native dotnetlibs/host_cmdline: libps-build/Makefile + cd libps-build && make VERBOSE=0 && cp monad_native ../dotnetlibs && cp libps.so ../dotnetlibs && cp host_cmdline ../dotnetlibs libps.so-test: dotnetlibs/libps.so dotnetlibs/monad_native cd dotnetlibs && LD_LIBRARY_PATH=. ./monad_native @@ -154,6 +154,7 @@ internal-prepare-exec_env: runps.sh $(POWERSHELL_RUN_TARGETS) dotnetlibs/corerun cp -r dotnetlibs/*.exe exec_env/app_base cp -r dotnetlibs/lib* exec_env/app_base cp -r dotnetlibs/corerun exec_env/app_base + cp dotnetlibs/host_cmdline exec_env/app_base cp -r ../ext-src/pester exec_env/app_base/Modules/Pester cp runps.sh exec_env/app_base @@ -165,6 +166,12 @@ run: $(RUN_TARGETS) internal-prepare-exec_env # execute a cmdlet, this will auto-load the utility module and print a, b and c in 3 lines cd exec_env/app_base && PSMODULEPATH=$(shell pwd)/exec_env/app_base/Modules LD_LIBRARY_PATH=. ./corerun powershell-simple.exe '"a","b","c","a","a" | Select-Object -Unique' +run-host: $(RUN_TARGETS) dotnetlibs/host_cmdline internal-prepare-exec_env + # check if corerun is the right one (could be the debug version) + if ! diff dotnetlibs/corerun $(MONAD_EXT)/coreclr/Release/corerun; then cp -r $(MONAD_EXT)/coreclr/Release/* dotnetlibs; fi + # execute a cmdlet, this will auto-load the utility module and print a, b and c in 3 lines + cd exec_env/app_base && PSMODULEPATH=$(shell pwd)/exec_env/app_base/Modules LD_LIBRARY_PATH=. ./host_cmdline powershell-simple.exe '"a","b","c","a","a" | Select-Object -Unique' + run-interactive: $(POWERSHELL_RUN_TARGETS) dotnetlibs/corerun dotnetlibs/Microsoft.PowerShell.Commands.Management.dll dotnetlibs/Microsoft.PowerShell.Commands.Utility.dll dotnetlibs/Microsoft.PowerShell.Security.dll dotnetlibs/api-ms-win-core-registry-l1-1-0.dll internal-prepare-exec_env # check if corerun is the right one (could be the debug version) if ! diff dotnetlibs/corerun $(MONAD_EXT)/coreclr/Release/corerun; then cp -r $(MONAD_EXT)/coreclr/Release/* dotnetlibs; fi diff --git a/scripts/powershell-run.mk b/scripts/powershell-run.mk index e7cb5c9260..712b75c692 100644 --- a/scripts/powershell-run.mk +++ b/scripts/powershell-run.mk @@ -5,7 +5,8 @@ # POWERSHELL_RUN_FOLDER=../src/powershell-run -POWERSHELL_RUN_SRCS=$(addprefix $(POWERSHELL_RUN_FOLDER)/, main.cs host.cs ui.cs rawui.cs readline.cs) +POWERSHELL_RUN_SRCS=$(addprefix $(POWERSHELL_RUN_FOLDER)/, main.cs host.cs ui.cs rawui.cs readline.cs powershell-run.assembly-info.cs) +POWERSHELL_SIMPLE_SRCS=$(addprefix $(POWERSHELL_RUN_FOLDER)/, powershell-simple.cs powershell-simple.assembly-info.cs) # direct dependencies to be linked in POWERSHELL_RUN_DEPS=dotnetlibs/System.Management.Automation.dll dotnetlibs/Microsoft.PowerShell.Commands.Management.dll dotnetlibs/$(ASSEMBLY_LOAD_CONTEXT_TARGET) @@ -16,7 +17,7 @@ POWERSHELL_RUN_TARGETS=dotnetlibs/powershell-run.exe dotnetlibs/powershell-simpl dotnetlibs/powershell-run.exe: $(POWERSHELL_RUN_SRCS) $(POWERSHELL_RUN_DEPS) $(CSC) -out:$@ -noconfig -nostdlib -target:exe $(POWERSHELL_RUN_REFS) $(COREREF) $(POWERSHELL_RUN_SRCS) -dotnetlibs/powershell-simple.exe: $(POWERSHELL_RUN_FOLDER)/powershell-run.cs $(POWERSHELL_RUN_DEPS) - $(CSC) -out:$@ -noconfig -nostdlib -target:exe $(POWERSHELL_RUN_REFS) $(COREREF) $(POWERSHELL_RUN_FOLDER)/powershell-run.cs +dotnetlibs/powershell-simple.exe: $(POWERSHELL_SIMPLE_SRCS) $(POWERSHELL_RUN_DEPS) + $(CSC) -out:$@ -noconfig -nostdlib -target:exe $(POWERSHELL_RUN_REFS) $(COREREF) $(POWERSHELL_SIMPLE_SRCS) diff --git a/src/assembly-info/Microsoft.Management.Infrastructure.assembly-info.cs b/src/assembly-info/Microsoft.Management.Infrastructure.assembly-info.cs index 8e1b67f88a..7773cc2a07 100644 --- a/src/assembly-info/Microsoft.Management.Infrastructure.assembly-info.cs +++ b/src/assembly-info/Microsoft.Management.Infrastructure.assembly-info.cs @@ -2,4 +2,5 @@ using System.Runtime.CompilerServices; using System.Reflection; [assembly:InternalsVisibleTo("System.Management.Automation")] [assembly:AssemblyFileVersionAttribute("1.0.0.0")] +[assembly:AssemblyVersion("1.0.0.0")] diff --git a/src/assembly-info/Microsoft.PowerShell.CoreCLR.AssemblyLoadContext.assembly-info.cs b/src/assembly-info/Microsoft.PowerShell.CoreCLR.AssemblyLoadContext.assembly-info.cs index f93af66d03..ddc37ef73c 100644 --- a/src/assembly-info/Microsoft.PowerShell.CoreCLR.AssemblyLoadContext.assembly-info.cs +++ b/src/assembly-info/Microsoft.PowerShell.CoreCLR.AssemblyLoadContext.assembly-info.cs @@ -2,3 +2,4 @@ using System.Runtime.CompilerServices; using System.Reflection; [assembly:InternalsVisibleTo("System.Management.Automation")] [assembly:AssemblyFileVersionAttribute("1.0.0.0")] +[assembly:AssemblyVersion("1.0.0.0")] diff --git a/src/assembly-info/System.Management.Automation.assembly-info.cs b/src/assembly-info/System.Management.Automation.assembly-info.cs index 0f646d9acc..13378a5573 100644 --- a/src/assembly-info/System.Management.Automation.assembly-info.cs +++ b/src/assembly-info/System.Management.Automation.assembly-info.cs @@ -8,6 +8,7 @@ using System.Reflection; [assembly:InternalsVisibleTo("Microsoft.PowerShell.CoreCLR.AssemblyLoadContext")] [assembly:InternalsVisibleTo("ps_test")] [assembly:AssemblyFileVersionAttribute("1.0.0.0")] +[assembly:AssemblyVersion("1.0.0.0")] // diff --git a/src/monad-native b/src/monad-native index a756ecaadf..f7396c9561 160000 --- a/src/monad-native +++ b/src/monad-native @@ -1 +1 @@ -Subproject commit a756ecaadfa486b77032e7cefeb75ac0f479b403 +Subproject commit f7396c956114223403f5d59a201eede3b0194fc0 diff --git a/src/powershell-run/powershell-run.assembly-info.cs b/src/powershell-run/powershell-run.assembly-info.cs new file mode 100644 index 0000000000..523523c72c --- /dev/null +++ b/src/powershell-run/powershell-run.assembly-info.cs @@ -0,0 +1,4 @@ +using System.Runtime.CompilerServices; +using System.Reflection; +[assembly:AssemblyFileVersionAttribute("1.0.0.0")] +[assembly:AssemblyVersion("1.0.0.0")] diff --git a/src/powershell-run/powershell-simple.assembly-info.cs b/src/powershell-run/powershell-simple.assembly-info.cs new file mode 100644 index 0000000000..523523c72c --- /dev/null +++ b/src/powershell-run/powershell-simple.assembly-info.cs @@ -0,0 +1,4 @@ +using System.Runtime.CompilerServices; +using System.Reflection; +[assembly:AssemblyFileVersionAttribute("1.0.0.0")] +[assembly:AssemblyVersion("1.0.0.0")] diff --git a/src/powershell-run/powershell-run.cs b/src/powershell-run/powershell-simple.cs similarity index 95% rename from src/powershell-run/powershell-run.cs rename to src/powershell-run/powershell-simple.cs index 1f358b780d..5b8ba1e31c 100644 --- a/src/powershell-run/powershell-run.cs +++ b/src/powershell-run/powershell-simple.cs @@ -8,6 +8,7 @@ using System.Management.Automation.Runspaces; using System.Management.Automation.Host; using System.Globalization; using System.Reflection; +using System.Runtime.InteropServices; namespace ps_hello_world { @@ -456,8 +457,11 @@ namespace ps_hello_world public static void init() { - string psBasePath = System.IO.Directory.GetCurrentDirectory(); - PowerShellAssemblyLoadContextInitializer.SetPowerShellAssemblyLoadContext(psBasePath); + //string psBasePath = System.IO.Directory.GetCurrentDirectory(); + //PowerShellAssemblyLoadContextInitializer.SetPowerShellAssemblyLoadContext(psBasePath); + + //Assembly a = Assembly.Load(new AssemblyName("System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")); + //Console.WriteLine("##########################\nloaded assembly a=" + a + " during init\n#########################"); // PH: this debugging requires a change in the core PS stuff that was stashed away // during source cleanup @@ -520,6 +524,19 @@ namespace ps_hello_world } } + public static void UnmanagedMain(int argc, [MarshalAs(UnmanagedType.LPArray,ArraySubType=UnmanagedType.LPStr,SizeParamIndex=0)] String[] argv) + { + init(); + List allArgs = new List(); + + for (int i = 0; i < argc; ++i) + { + allArgs.Add(argv[i]); + } + + test2(allArgs.ToArray()); + } + static void Main(string[] args) { // important: