public void Remove(DirectoryPath value, PathSettings pathSettings) { if (value == null) { throw new ArgumentNullException(nameof(value), "Value to add to path is null."); } if (pathSettings == null) { throw new ArgumentNullException(nameof(pathSettings), "Path settings is null."); } var pathTarget = pathSettings .Target .GetValueOrDefault(PathTarget.User); var parts = _environmentWrapper .GetEnvironmentVariable("PATH", pathTarget, string.Empty) .Split(';') .Where(x => !string.IsNullOrWhiteSpace(x)) .ToList(); if (!parts.Remove(value.FullPath)) { _log.Verbose($"PATH does not contain '{value}'."); return; } _environmentWrapper.SetEnvironmentVariable("PATH", string.Join(";", parts), pathTarget); _log.Verbose($"Removed '{value}' from PATH."); }
public string Get(PathSettings pathSettings) { var pathTarget = pathSettings .Target .GetValueOrDefault(PathTarget.User); return(_environmentWrapper.GetEnvironmentVariable("PATH", pathTarget, string.Empty)); }
public static void AddToPath(this ICakeContext context, DirectoryPath value, PathSettings pathSettings) { if (context == null) { throw new ArgumentNullException(nameof(context)); } PathWrapper.Load(context.Log) .Add(value, pathSettings); }
public static string GetEnvironmentPath(this ICakeContext context, PathSettings pathSettings) { if (context == null) { throw new ArgumentNullException(nameof(context)); } return(PathWrapper.Load(context.Log) .Get(pathSettings)); }