private string ParseUri(string uri, ILogger logger) { if (uri.StartsWith("file://")) { return(new Uri(uri).LocalPath); } if (uri.StartsWith("http")) { // // Remote // try { Uri remoteUri = new Uri(uri); string powershellText = _fileProvider.Download(remoteUri); string tempFilename = _fileProvider.WriteTemporaryFile(powershellText); return(tempFilename); } catch (WebException e) { logger.Error($"Unable to download '{uri}' - {e.Message}", e); return(null); } catch (IOException e) { logger.Error(e.Message); return(null); } } else { // // Local // if (uri.StartsWith("./")) { uri = Path.Combine(_fileProvider.GetCurrentDirectory(), uri); } else if (!uri.Contains(Environment.NewLine)) { uri = Path.Combine(_fileProvider.GetCurrentDirectory(), uri); } Uri fileUri = new Uri("file://" + uri); return(fileUri.LocalPath); } }