@@ -75,20 +75,28 @@ public PowerShellContextState SessionState
75
75
private set ;
76
76
}
77
77
78
+ /// <summary>
79
+ /// Gets the PowerShell version details for the current runspace.
80
+ /// </summary>
81
+ public PowerShellVersionDetails PowerShellVersionDetails
82
+ {
83
+ get ; private set ;
84
+ }
85
+
78
86
/// <summary>
79
87
/// Gets the PowerShell version of the current runspace.
80
88
/// </summary>
81
89
public Version PowerShellVersion
82
90
{
83
- get ; private set ;
91
+ get { return this . PowerShellVersionDetails . Version ; }
84
92
}
85
93
86
94
/// <summary>
87
95
/// Gets the PowerShell edition of the current runspace.
88
96
/// </summary>
89
97
public string PowerShellEdition
90
98
{
91
- get ; private set ;
99
+ get { return this . PowerShellVersionDetails . Edition ; }
92
100
}
93
101
94
102
/// <summary>
@@ -188,9 +196,7 @@ private void Initialize(ProfilePaths profilePaths, Runspace initialRunspace)
188
196
this . powerShell . Runspace = this . currentRunspace ;
189
197
190
198
// Get the PowerShell runtime version
191
- Tuple < Version , string > versionEditionTuple = GetPowerShellVersion ( ) ;
192
- this . PowerShellVersion = versionEditionTuple . Item1 ;
193
- this . PowerShellEdition = versionEditionTuple . Item2 ;
199
+ this . PowerShellVersionDetails = GetPowerShellVersion ( ) ;
194
200
195
201
// Write out the PowerShell version for tracking purposes
196
202
Logger . Write (
@@ -246,10 +252,12 @@ private void Initialize(ProfilePaths profilePaths, Runspace initialRunspace)
246
252
this . runspaceWaitQueue . EnqueueAsync ( runspaceHandle ) . Wait ( ) ;
247
253
}
248
254
249
- private Tuple < Version , string > GetPowerShellVersion ( )
255
+ private PowerShellVersionDetails GetPowerShellVersion ( )
250
256
{
251
257
Version powerShellVersion = new Version ( 5 , 0 ) ;
258
+ string versionString = null ;
252
259
string powerShellEdition = "Desktop" ;
260
+ string architecture = "Unknown" ;
253
261
254
262
try
255
263
{
@@ -267,14 +275,26 @@ private Tuple<Version, string> GetPowerShellVersion()
267
275
{
268
276
powerShellEdition = edition ;
269
277
}
278
+
279
+ var gitCommitId = psVersionTable [ "GitCommitId" ] as string ;
280
+ if ( gitCommitId != null )
281
+ {
282
+ versionString = gitCommitId ;
283
+ }
284
+
285
+ architecture = this . currentRunspace . SessionStateProxy . GetVariable ( "env:PROCESSOR_ARCHITECTURE" ) as string ;
270
286
}
271
287
}
272
288
catch ( Exception ex )
273
289
{
274
290
Logger . Write ( LogLevel . Warning , "Failed to look up PowerShell version. Defaulting to version 5. " + ex . Message ) ;
275
291
}
276
292
277
- return new Tuple < Version , string > ( powerShellVersion , powerShellEdition ) ;
293
+ return new PowerShellVersionDetails (
294
+ powerShellVersion ,
295
+ versionString ,
296
+ powerShellEdition ,
297
+ architecture ) ;
278
298
}
279
299
280
300
#endregion
0 commit comments