public override object GetValue(MemberInfo member, object instance)
    {
        var name = _name ?? member.Name;

        return(new Lazy <Tool>(() => ToolResolver.TryGetEnvironmentTool(name) ??
                               ToolResolver.GetPathTool(name)));
    }
Ejemplo n.º 2
0
        public static void ManualToolresolvingMeandering()
        {
            string TryGetPathExe(string exe)
            {
                try
                {
                    return(ToolPathResolver.GetPathExecutable(exe));
                }
                catch
                {
                }

                return(string.Empty);
            }

            string TryGetPathToolExe(string exe)
            {
                try
                {
                    return(ToolPathResolver.TryGetEnvironmentExecutable(exe));
                }
                catch
                {
                }

                return(string.Empty);
            }

            //ToolResolver.GetPathTool(exe)

            //ToolResolver.GetPathTool("appveyor");
            //Tool myTool = ToolResolver.GetPathTool(exe)
            void TryAndGetPathEXEAndPrint(string exe)
            {
                Logger.Normal($"Trying to get exe {exe}: '{TryGetPathExe(exe)}'");
            }

            var executables = new[] { "DOES NOT EXIST", "powershell", "bash" };

            //ToolPathResolver.GetPathExecutable - get something on the path
            //vs TryGetEnvironmentExecutable             //ToolPathResolver.TryGetEnvironmentExecutable -- this will get an exe defined by an enviornment variable
            //vs ToolResolver.GetPathTool(exe) - get a tool in the user's path based on
            executables.ForEach(TryAndGetPathEXEAndPrint);
            Logger.Normal($"Comspec is set up by something on windows systems as a standard exe tool, so here is the path {TryGetPathToolExe("ComSpec")}");
            Tool git = ToolResolver.GetPathTool("git");

#pragma warning disable 168
            //just showing that ControlFlow.Fail throws an "Exception" object that is not sub-typed
            try
            {
                Tool doesNotExist = ToolResolver.GetPathTool("DOES NOT EXIST");
            }catch (Exception e) {}
            try
            {
                ControlFlow.Fail("TEST same as trying to get non existent tool with tool resolver");
            }catch (Exception e) {}
#pragma warning restore 168
        }
Ejemplo n.º 3
0
        protected override void ExecuteStep()
        {
            var metrics = ToolResolver.GetPackageTool("Microsoft.CodeAnalysis.Metrics", "Metrics.exe");

            metrics($"/SOLUTION:\"{Config.Solution}\" /OUT:\"{Config.XmlReportFile}\"");

            TransformMetricsResults();
            FailTargetOnTooLowMaintainability();
        }
Ejemplo n.º 4
0
        public NuGetPackageInstallerFixture()
        {
            Environment     = FakeEnvironment.CreateUnixEnvironment();
            FileSystem      = new FakeFileSystem(Environment);
            ProcessRunner   = Substitute.For <IProcessRunner>();
            ContentResolver = Substitute.For <INuGetPackageContentResolver>();
            Log             = Substitute.For <ICakeLog>();

            ToolResolver = Substitute.For <INuGetToolResolver>();
            ToolResolver.ResolvePath().Returns(new FilePath("/Working/tools/nuget.exe"));

            Package     = new PackageReference("nuget:https://myget.org/temp/?package=Cake.Foo&prerelease&version=1.2.3");
            PackageType = PackageType.Addin;
            InstallPath = new DirectoryPath("./nuget");
        }
Ejemplo n.º 5
0
    protected override void OnBuildInitialized()
    {
        base.OnBuildInitialized();
        BuildInitialized?.Invoke();
        OnGitFlowInitialized();

        if (IsWin)
        {
            BuildScript = ToolResolver.GetLocalTool(RootDirectory / "build.cmd");
        }
        else
        {
            BuildScript = ToolResolver.GetLocalTool(RootDirectory / "build.sh");
        }
    }
Ejemplo n.º 6
0
    void RunProtoc(string options, string absolutePath)
    {
        Logger.Normal($"where we are generating protobufs from {absolutePath}");
        PlatformFamily platform        = EnvironmentInfo.Platform;
        var            protocEXELookup = new Dictionary <PlatformFamily, string>()
        {
            { PlatformFamily.OSX, "protoc_mac" },
            { PlatformFamily.Linux, "protoc_linux" },
            { PlatformFamily.Windows, "protoc.exe" }
        };
        AbsolutePath protocLocation = RootDirectory / $"tools/protoc/{protocEXELookup[platform]}";
        var          protocTool     = ToolResolver.GetLocalTool(protocLocation);

        protocTool.Invoke($"{options}", absolutePath);
    }
Ejemplo n.º 7
0
 void SymlinkFile(AbsolutePath originPath, AbsolutePath toPointToOriginPath)
 {
     DelFileOrDir(toPointToOriginPath);
     //if(Directory.Exists(toPointToOriginPath)) Directory.Delete(toPointToOriginPath);
     if (EnvironmentInfo.Platform == PlatformFamily.Windows)
     {
         string flag = "";
         if (!File.Exists(originPath) && Directory.Exists(originPath))
         {
             flag = " /j ";
         }
         ToolResolver.GetPathTool("cmd").Invoke($"/c mklink {flag} {toPointToOriginPath} {originPath}");
     }
     else
     {
         ToolResolver.GetPathTool("ln").Invoke($" -s {originPath} {toPointToOriginPath}");
     }
 }
        public NuGetPackageInstallerFixture()
        {
            Environment     = FakeEnvironment.CreateUnixEnvironment();
            FileSystem      = new FakeFileSystem(Environment);
            ContentResolver = Substitute.For <INuGetContentResolver>();
            Log             = Substitute.For <ICakeLog>();
            Config          = Substitute.For <ICakeConfiguration>();

            ToolResolver = Substitute.For <INuGetToolResolver>();
            ToolResolver.ResolvePath().Returns(new FilePath("/Working/tools/nuget.exe"));

            Package     = new PackageReference("nuget:https://myget.org/temp/?package=Cake.Foo&prerelease&version=1.2.3");
            PackageType = PackageType.Addin;
            InstallPath = new DirectoryPath("./nuget");

            ProcessRunner = Substitute.For <IProcessRunner>();
            ProcessRunner.When(p => p.Start(Arg.Any <FilePath>(), Arg.Any <ProcessSettings>()))
            .Do(info => FileSystem.CreateDirectory(InstallPath.Combine(Package.Package.ToLowerInvariant()).Combine(Package.Package)));
        }
Ejemplo n.º 9
0
 internal AppVeyor()
 {
     _cli = ToolResolver.GetPathTool("appveyor");
 }
 public override object GetValue(MemberInfo member, object instance)
 {
     return(new Lazy <Tool>(() => ToolResolver.GetLocalTool(_absoluteOrRelativePath)));
 }
Ejemplo n.º 11
0
 public ToolContainer(IWindsorContainer container)
 {
     this.container = container;
     Register       = new ToolRegistrator(this);
     Resolve        = new ToolResolver(container);
 }