10
10
using System . Collections . Concurrent ;
11
11
using System . Diagnostics ;
12
12
using System . IO ;
13
- #if CoreCLR
14
13
using System . Reflection ;
15
- #endif
16
14
using System . Text ;
17
15
using System . Threading ;
18
16
using System . Threading . Tasks ;
@@ -21,6 +19,7 @@ namespace Microsoft.PowerShell.EditorServices.Test.Host
21
19
{
22
20
public class ServerTestsBase
23
21
{
22
+ private static int sessionCounter ;
24
23
private Process serviceProcess ;
25
24
protected IMessageSender messageSender ;
26
25
protected IMessageHandlers messageHandlers ;
@@ -39,15 +38,18 @@ protected async Task<Tuple<int, int>> LaunchService(
39
38
string scriptPath = Path . Combine ( modulePath , "Start-EditorServices.ps1" ) ;
40
39
41
40
#if CoreCLR
42
- string assemblyPath = this . GetType ( ) . GetTypeInfo ( ) . Assembly . Location ;
43
- FileVersionInfo fileVersionInfo =
44
- FileVersionInfo . GetVersionInfo ( assemblyPath ) ;
41
+ Assembly assembly = this . GetType ( ) . GetTypeInfo ( ) . Assembly ;
45
42
#else
46
- string assemblyPath = this . GetType ( ) . Assembly . Location ;
43
+ Assembly assembly = this . GetType ( ) . Assembly ;
44
+ #endif
45
+
46
+ string assemblyPath = new Uri ( assembly . CodeBase ) . LocalPath ;
47
47
FileVersionInfo fileVersionInfo =
48
48
FileVersionInfo . GetVersionInfo ( assemblyPath ) ;
49
- #endif
50
- string sessionPath = Path . Combine ( Path . GetDirectoryName ( assemblyPath ) , "session.json" ) ;
49
+
50
+ string sessionPath =
51
+ Path . Combine (
52
+ Path . GetDirectoryName ( assemblyPath ) , $ "session-{ ++ sessionCounter } .json") ;
51
53
52
54
string editorServicesModuleVersion =
53
55
string . Format (
@@ -105,7 +107,7 @@ protected async Task<Tuple<int, int>> LaunchService(
105
107
this . serviceProcess . Start ( ) ;
106
108
107
109
// Wait for the server to finish initializing
108
- while ( ! File . Exists ( sessionPath ) && new FileInfo ( assemblyPath ) . Length > 0 )
110
+ while ( ! File . Exists ( sessionPath ) || ( new FileInfo ( sessionPath ) . Length == 0 ) )
109
111
{
110
112
Thread . Sleep ( 100 ) ;
111
113
}
0 commit comments