예제 #1
0
        public override object GetValue(MemberInfo member, object instance)
        {
            var toolPath = ToolPathResolver.TryGetEnvironmentExecutable($"{member.Name.ToUpperInvariant()}_EXE") ??
                           ToolPathResolver.GetPackageExecutable(_packageId, _packageExecutable, Framework);

            return(new Tool(new ToolExecutor(toolPath).Execute));
        }
예제 #2
0
        public override object GetValue(MemberInfo member, object instance)
        {
            var name     = _name ?? member.Name;
            var toolPath = ToolPathResolver.TryGetEnvironmentExecutable($"{name.ToUpperInvariant()}_EXE") ??
                           ToolPathResolver.GetPathExecutable(name);

            return(new Tool(new ToolExecutor(toolPath).Execute));
        }
예제 #3
0
        public static Tool TryGetEnvironmentTool(string name)
        {
            var toolPath = ToolPathResolver.TryGetEnvironmentExecutable($"{name.ToUpperInvariant()}_EXE");

            if (toolPath == null)
            {
                return(null);
            }

            return(new ToolExecutor(toolPath).Execute);
        }
예제 #4
0
        public virtual IProcess StartProcess(
            string toolPath,
            string executionArguments = null,
            string outputArguments    = null,
            string workingDirectory   = null,
            IReadOnlyDictionary <string, string> environmentVariables = null,
            int?timeout    = null,
            bool logOutput = true,
            Func <string, LogLevel> logLevelParser = null,
            Func <string, string> outputFilter     = null)
        {
            ControlFlow.Assert(toolPath != null, "ToolPath was not set.");
            if (!Path.IsPathRooted(toolPath) && !toolPath.Contains(Path.DirectorySeparatorChar))
            {
                toolPath = ToolPathResolver.GetPathExecutable(toolPath);
            }

#if NETCORE
            string toolPathOverride = null;
            if (toolPath.EndsWith(".dll"))
            {
                toolPathOverride = ToolPathResolver.TryGetEnvironmentExecutable("DOTNET_EXE") ??
                                   ToolPathResolver.GetPathExecutable("dotnet");
            }
            else if (EnvironmentInfo.IsUnix && toolPath.EndsWithOrdinalIgnoreCase(".exe"))
            {
                toolPathOverride = ToolPathResolver.GetPathExecutable("mono");
            }

            if (!string.IsNullOrEmpty(toolPathOverride))
            {
                executionArguments = $"{toolPath.DoubleQuoteIfNeeded()} {executionArguments}".TrimEnd();
                outputArguments    = $"{toolPath.DoubleQuoteIfNeeded()} {outputArguments}".TrimEnd();
                toolPath           = toolPathOverride;
            }
#endif

            outputArguments = outputArguments ?? (outputFilter == null ? executionArguments : outputFilter(executionArguments));
            ControlFlow.Assert(File.Exists(toolPath), $"ToolPath '{toolPath}' does not exist.");
            Logger.Info($"> {Path.GetFullPath(toolPath).DoubleQuoteIfNeeded()} {outputArguments}");

            return(StartProcessInternal(toolPath,
                                        executionArguments,
                                        workingDirectory,
                                        environmentVariables,
                                        timeout,
                                        logOutput,
                                        logLevelParser,
                                        outputFilter ?? (x => x)));
        }
예제 #5
0
        private static string GetToolPathOverride(string toolPath)
        {
            if (toolPath.EndsWithOrdinalIgnoreCase(".dll"))
            {
                return(ToolPathResolver.TryGetEnvironmentExecutable("DOTNET_EXE") ??
                       ToolPathResolver.GetPathExecutable("dotnet"));
            }

#if NETCORE
            if (EnvironmentInfo.IsUnix && toolPath.EndsWithOrdinalIgnoreCase(".exe"))
            {
                return(ToolPathResolver.GetPathExecutable("mono"));
            }
#endif

            return(null);
        }