Bari.Core.Tools.ManuallyInstallableExternalTool.EnsureToolAvailable C# (CSharp) Method

EnsureToolAvailable() protected method

Checks if the tool is available and download, copy, install etc. it if possible

If the tool cannot be acquired then it throws an exception.

protected EnsureToolAvailable ( ) : void
return void
        protected override void EnsureToolAvailable()
        {
            bool exists;
            if (!Path.IsPathRooted(ToolPath))
            {
                var paths = Environment.GetEnvironmentVariable("PATH").Split(Path.PathSeparator);
                exists = paths.Any(path =>
                {
                    var possibility = Path.Combine(path, ToolPath);
                    log.DebugFormat("Trying {0}", possibility);
                    return File.Exists(possibility);
                });
            }
            else
            {
                exists = File.Exists(ToolPath);
            }

            if (!exists)
            {
                throw new ToolMustBeInstalledManually(Name, manualUri);
            }
        }