@@ -69,10 +69,17 @@ public string LocalAppDataPath
6969 }
7070 private set
7171 {
72+ #if CORECLR
73+ localAppdataPath
74+ = string . IsNullOrWhiteSpace ( value )
75+ ? Environment . GetEnvironmentVariable ( "LOCALAPPDATA" )
76+ : value ;
77+ #else
7278 localAppdataPath
7379 = string . IsNullOrWhiteSpace ( value )
7480 ? Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData )
7581 : value ;
82+ #endif
7683 }
7784 }
7885
@@ -194,7 +201,8 @@ private string GetPSSATempDirPath()
194201 private string GetTempModulePath ( string symLinkPath )
195202 {
196203 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 ) )
198206 {
199207 line = fileStream . ReadLine ( ) ;
200208 }
@@ -220,12 +228,21 @@ private void SetupPSModulePath()
220228 {
221229 oldPSModulePath = Environment . GetEnvironmentVariable ( "PSModulePath" ) ;
222230 curPSModulePath = oldPSModulePath + ";" + tempModulePath ;
231+ #if CORECLR
232+ Environment . SetEnvironmentVariable ( "PSModulePath" , curPSModulePath ) ;
233+ #else
223234 Environment . SetEnvironmentVariable ( "PSModulePath" , curPSModulePath , EnvironmentVariableTarget . Process ) ;
235+ #endif
224236 }
225237
226238 private void RestorePSModulePath ( )
227239 {
240+
241+ #if CORECLR
242+ Environment . SetEnvironmentVariable ( "PSModulePath" , oldPSModulePath ) ;
243+ #else
228244 Environment . SetEnvironmentVariable ( "PSModulePath" , oldPSModulePath , EnvironmentVariableTarget . Process ) ;
245+ #endif
229246 }
230247#endregion Private Methods
231248
0 commit comments