diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
index 7d2a705d97..a5a0bb0ced 100644
--- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
+++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs
@@ -1612,6 +1612,7 @@ namespace Microsoft.PowerShell
OpenConsoleRunspace(consoleRunspace, staMode);
}
+ Runspace.PrimaryRunspace = consoleRunspace;
_runspaceRef = new RunspaceRef(consoleRunspace);
if (psReadlineFailed)
@@ -1656,10 +1657,8 @@ namespace Microsoft.PowerShell
#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 3774aa40dc..136ab9e1df 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