diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
index 7d2a705d973..a5a0bb0cedb 100644
--- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
+++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
@@ -1612,6 +1612,7 @@ private void DoCreateRunspace(string initialCommand, bool skipProfiles, bool sta
OpenConsoleRunspace(consoleRunspace, staMode);
}
+ Runspace.PrimaryRunspace = consoleRunspace;
_runspaceRef = new RunspaceRef(consoleRunspace);
if (psReadlineFailed)
@@ -1656,10 +1657,8 @@ private void OpenConsoleRunspace(Runspace runspace, bool staMode)
#endif
runspace.ThreadOptions = PSThreadOptions.ReuseThread;
runspace.EngineActivityId = EtwActivity.GetActivityId();
- Runspace.PrimaryRunspace = runspace;
s_runspaceInitTracer.WriteLine("Calling Runspace.Open");
-
runspace.Open();
}
diff --git a/src/powershell-win-core/powershell-win-core.csproj b/src/powershell-win-core/powershell-win-core.csproj
index 3774aa40dc1..136ab9e1df7 100644
--- a/src/powershell-win-core/powershell-win-core.csproj
+++ b/src/powershell-win-core/powershell-win-core.csproj
@@ -12,6 +12,7 @@
powershell.config.json
+ PreserveNewest
PreserveNewest