Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tool resolving in Frosting tasks #3038

Closed
pascalberger opened this issue Jan 18, 2021 · 8 comments · Fixed by #3048
Closed

Tool resolving in Frosting tasks #3038

pascalberger opened this issue Jan 18, 2021 · 8 comments · Fixed by #3048
Labels
Projects
Milestone

Comments

@pascalberger
Copy link
Member

pascalberger commented Jan 18, 2021

What You Are Seeing?

I can restore a .NET Tool using the Cake.DotNet.Module and then call it in the build context constructor. But when calling the same tool in the Setup or a task an error is thrown:

Error: GitVersion: Could not locate executable.

What is Expected?

It should be possible to call .NET Tools also from setup or tasks.

What version of Cake are you using?

1.0.0-rc0002

Are you running on a 32 or 64 bit system?

64-Bit

What environment are you running on? Windows? Linux? Mac?

Windows

Are you running on a CI Server? If so, which one?

No

How Did You Get This To Happen? (Steps to Reproduce)

  1. Create a new Froasting project and setup the host like this:

    return new CakeHost()
        .UseContext<BuildContext>()
        .UseModule<DotNetToolModule>()
        .UseTool(new Uri("dotnet:?package=GitVersion.Tool&version=5.6.3"))
        .Run(args);
    
  2. Call context.GitVersion(); in the constructor of the BuildContext class

  3. Call context.GitVersion(); in a task

@pascalberger pascalberger added this to the v1.0.0 milestone Jan 23, 2021
@pascalberger pascalberger added this to To do in 1.0.0 Jan 23, 2021
@pascalberger
Copy link
Member Author

This is caused by working directory and probably a duplicate of #2904

@patriksvensson
Copy link
Member

@pascalberger Can't reproduce. I'm closing the issue.

image

@pascalberger
Copy link
Member Author

I'll add a repro repository later

@pascalberger pascalberger reopened this Jan 23, 2021
@pascalberger
Copy link
Member Author

Here's a repository where it can be reproduced: https://github.com/pascalberger/cake-gh-3038

For the reproduction to work it is important that GitVersion is not available on the system (e.g. installed as .NET global tool or through Chocolatey). In this case the behavior can still be seen when running with diagnostic verbosity where it is visible that global instance is called when running from a task instead of the version installed in the build script (see this GitHub actions run: https://github.com/pascalberger/cake-gh-3038/runs/1758010781?check_suite_focus=true#step:5:36).

@augustoproiete
Copy link
Member

augustoproiete commented Jan 24, 2021

Here's a repository where it can be reproduced: https://github.com/pascalberger/cake-gh-3038

I can repro on my machine:

.\build.ps1 --verbosity=diagnostic
Tool GitVersion.Tool is already installed, with required version.
Building version 0.1.0...
Registering task: Default

========================================
Default
========================================
Executing task: Default
Could not resolve path for tool "GitVersion.exe" using these directories: C:/Program Files/WindowsApps/Microsoft.WindowsTerminal_1.4.3243.0_x64__8wekyb3d8bbwe,C:/WINDOWS/system32,C:/WINDOWS,C:/WINDOWS/System32/Wbem,C:/WINDOWS/System32/WindowsPowerShell/v1.0,(...),C:/Users/augustoproiete/.dotnet/tools
An error occurred when executing task 'Default'.
Error: Cake.Core.CakeException: GitVersion: Could not locate executable.
   at Cake.Core.Tooling.Tool`1.RunProcess(TSettings settings, ProcessArgumentBuilder arguments, ProcessSettings processSettings)
   at Cake.Core.Tooling.Tool`1.Run(TSettings settings, ProcessArgumentBuilder arguments, ProcessSettings processSettings, Action`1 postAction)
   at Cake.Common.Tools.GitVersion.GitVersionRunner.Run(GitVersionSettings settings)
   at Cake.Common.Tools.GitVersion.GitVersionAliases.GitVersion(ICakeContext context, GitVersionSettings settings)
   at Cake.Common.Tools.GitVersion.GitVersionAliases.GitVersion(ICakeContext context)
   at DefaultTask.Run(ICakeContext context) in C:\augustoproiete\cake-build--\pascalberger--cake-gh-3038\build\Tasks\DefaultTask.cs:line 13
   at Cake.Frosting.FrostingTask`1.Cake.Frosting.IFrostingTask.RunAsync(ICakeContext context)
   at Cake.Core.CakeTask.Execute(ICakeContext context)
   at Cake.Core.DefaultExecutionStrategy.ExecuteAsync(CakeTask task, ICakeContext context)
   at Cake.Core.CakeEngine.ExecuteTaskAsync(ICakeContext context, IExecutionStrategy strategy, Stopwatch stopWatch, CakeTask task, CakeReport report)
   at Cake.Core.CakeEngine.ExecuteTaskAsync(ICakeContext context, IExecutionStrategy strategy, Stopwatch stopWatch, CakeTask task, CakeReport report)
   at Cake.Core.CakeEngine.ExecuteTaskAsync(ICakeContext context, IExecutionStrategy strategy, Stopwatch stopWatch, CakeTask task, CakeReport report)
   at Cake.Core.CakeEngine.RunTask(ICakeContext context, IExecutionStrategy strategy, CakeTask task, String target, Stopwatch stopWatch, CakeReport report)

@pascalberger
Copy link
Member Author

Error is triggered by setting working directory and might be fixed with #3048.

@pascalberger pascalberger moved this from To do to In progress in 1.0.0 Jan 24, 2021
@pascalberger pascalberger linked a pull request Jan 24, 2021 that will close this issue
@pascalberger
Copy link
Member Author

Fixed with #3048

@pascalberger pascalberger moved this from In progress to Done in 1.0.0 Jan 24, 2021
bdukes added a commit to bdukes/Dnn.Platform that referenced this issue Jan 26, 2021
Because of cake-build/cake#3038 the tools
folder isn't being accessed correctly, but this can use the version
of the NuGet package installed by the test projects themselves.
@cake-build-bot
Copy link

🎉 This issue has been resolved in version v1.0.0 🎉

The release is available on:

Your GitReleaseManager bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
1.0.0
Done
Development

Successfully merging a pull request may close this issue.

5 participants