@@ -69,10 +69,17 @@ public string LocalAppDataPath
69
69
}
70
70
private set
71
71
{
72
+ #if CORECLR
73
+ localAppdataPath
74
+ = string . IsNullOrWhiteSpace ( value )
75
+ ? Environment . GetEnvironmentVariable ( "LOCALAPPDATA" )
76
+ : value ;
77
+ #else
72
78
localAppdataPath
73
79
= string . IsNullOrWhiteSpace ( value )
74
80
? Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData )
75
81
: value ;
82
+ #endif
76
83
}
77
84
}
78
85
@@ -194,7 +201,8 @@ private string GetPSSATempDirPath()
194
201
private string GetTempModulePath ( string symLinkPath )
195
202
{
196
203
string line ;
197
- using ( var fileStream = new StreamReader ( symLinkPath ) )
204
+ using ( var file = File . Open ( symLinkPath , FileMode . Open ) )
205
+ using ( var fileStream = new StreamReader ( file ) )
198
206
{
199
207
line = fileStream . ReadLine ( ) ;
200
208
}
@@ -220,12 +228,21 @@ private void SetupPSModulePath()
220
228
{
221
229
oldPSModulePath = Environment . GetEnvironmentVariable ( "PSModulePath" ) ;
222
230
curPSModulePath = oldPSModulePath + ";" + tempModulePath ;
231
+ #if CORECLR
232
+ Environment . SetEnvironmentVariable ( "PSModulePath" , curPSModulePath ) ;
233
+ #else
223
234
Environment . SetEnvironmentVariable ( "PSModulePath" , curPSModulePath , EnvironmentVariableTarget . Process ) ;
235
+ #endif
224
236
}
225
237
226
238
private void RestorePSModulePath ( )
227
239
{
240
+
241
+ #if CORECLR
242
+ Environment . SetEnvironmentVariable ( "PSModulePath" , oldPSModulePath ) ;
243
+ #else
228
244
Environment . SetEnvironmentVariable ( "PSModulePath" , oldPSModulePath , EnvironmentVariableTarget . Process ) ;
245
+ #endif
229
246
}
230
247
#endregion Private Methods
231
248
0 commit comments