@@ -41,6 +41,7 @@ public class UseCompatibleCmdlets : AstVisitor, IScriptRule
4141 private Dictionary < string , dynamic > platformSpecMap ;
4242 private string scriptPath ;
4343 private bool IsInitialized ;
44+ private readonly string referenceFile = "desktop-5.1.14393.206-windows.json" ;
4445
4546 public UseCompatibleCmdlets ( )
4647 {
@@ -271,7 +272,15 @@ private void SetupCmdletsDictionary()
271272 switch ( mode )
272273 {
273274 case "offline" :
274- ProcessOfflineModeArgs ( ruleArgs ) ;
275+ var uri = GetStringArgFromListStringArg ( ruleArgs [ "uri" ] ) ;
276+ if ( uri == null
277+ || ! Directory . Exists ( uri )
278+ || ! ContainsReferenceFile ( uri ) )
279+ {
280+ return ;
281+ }
282+
283+ ProcessDirectory ( uri ) ;
275284 break ;
276285
277286 case "online" : // not implemented yet.
@@ -284,14 +293,24 @@ private void SetupCmdletsDictionary()
284293 }
285294
286295 var settingsPath = GetShippedSettingsDirectory ( ) ;
287- if ( settingsPath == null )
296+ if ( settingsPath == null
297+ || ! ContainsReferenceFile ( settingsPath ) )
288298 {
289299 return ;
290300 }
291301
292302 ProcessDirectory ( settingsPath ) ;
293303 }
294304
305+ /// <summary>
306+ /// Checks if the given directory has the reference file
307+ /// directory must be non-null
308+ /// </summary>
309+ private bool ContainsReferenceFile ( string directory )
310+ {
311+ return File . Exists ( Path . Combine ( directory , referenceFile ) ) ;
312+ }
313+
295314 /// <summary>
296315 /// Resets the values in curCmdletCompatibilityMap to true
297316 /// </summary>
0 commit comments