cake-build / cake-build/cake

DotNetTool Module: Not using the same version of dotnet as Cake DotNetCoreTool

Open
#3,210 3 comments 0 reactions 0 assignees View on GitHub
Bug Help wanted Up-for-grabs
Dominant language
C#
Stars
4.2k
Forks
778
Avg merge
1h 15m
Merged PRs (30d)
19

Description

> Creating a new issue for tracking https://github.com/cake-contrib/Cake.DotNetTool.Module/issues/21 created by @brianfeucht given that GitHub doesn't allow transferring issues from one organization to another.

---

@brianfeucht wrote:

I'm running into an issue where the Cake `DotNetCoreTool` is not able to find the tool installed with this module. It looks like the underlying issue is due to Cake and this module using different versions of the dotnet cli tool.

## Expected Behavior
The module and Cake use same dotnet cli version so I'm able to use the tool installed with this module.

## Current Behavior
Log from my CAKE script:
```
Installing tools...
Configured Tools Folder: Z:/Teamcity/Work/3aedfc86eaf25d80/scripts/tools
Executing: "dotnet" tool list --global
Package Id Version Commands
---------------------------------------------------
amazon.lambda.tools 4.0.0 dotnet-lambda
Adding tool amazon.lambda.tools
There are 1 dotnet tools installed
Checking for tool: amazon.lambda.tools
Tool Amazon.Lambda.Tools is already installed, with required version.
Tool Folder: C:/Windows/system32/config/systemprofile/.dotnet/tools/.store/amazon.lambda.tools
Found 10 files in tool folder
```
```
Executing: "C:/Program Files/dotnet/dotnet.exe" lambda package
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET Core program, but dotnet-lambda does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
Executing custom task teardown action (PackageLambda)...
An error occurred when executing task 'PackageLambda'.
Error: System.AggregateException: One or more errors occurred. ---> Cake.Core.CakeException: .NET Core CLI: Process returned an error (exit code 1).
at Cake.Core.Tooling.Tool`1.ProcessExitCode(Int32 exitCode)
at Cake.Core.Tooling.Tool`1.Run(TSettings settings, ProcessArgumentBuilder arguments, ProcessSettings processSettings, Action`1 postAction)
at Cake.Common.Tools.DotNetCore.Tool.DotNetCoreToolRunner.Execute(FilePath projectPath, String command, ProcessArgumentBuilder arguments, DotNetCoreToolSettings settings)
at Cake.Common.Tools.DotNetCore.DotNetCoreAliases.DotNetCoreTool(ICakeContext context, FilePath projectPath, String command, ProcessArgumentBuilder arguments)
at Submission#0.DotNetCoreTool(FilePath projectPath, String command, ProcessArgumentBuilder arguments) in :line 1058
at Submission#0.<>b__0_0() in Z:\Teamcity\Work\3aedfc86eaf25d80\scripts\Package.cake:line 92
at Cake.Core.CakeTaskBuilderExtensions.<>c__DisplayClass32_0.b__0(ICakeContext x)
at Cake.Core.CakeTask.d__43.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.DefaultExecutionStrategy.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.CakeEngine.d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Cake.Core.CakeEngine.d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Cake.Core.CakeEngine.d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.CakeEngine.d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Cake.Core.CakeEngine.d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Scripting.BuildScriptHost.d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.Scripting.ScriptHost.RunTarget(String target)
at Submission#0.<>d__0.MoveNext() in Z:\Teamcity\Work\3aedfc86eaf25d80\scripts\build.cake:line 109
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.d__9`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.Scripting.Script`1.d__21.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Cake.Scripting.Roslyn.RoslynScriptSession.Execute(Script script)
at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments)
at Cake.Commands.BuildCommand.Execute(CakeOptions options)
at Cake.CakeApplication.Run(CakeOptions options)
at Cake.Program.Main()
---> (Inner Exception #0) Cake.Core.CakeException: .NET Core CLI: Process returned an error (exit code 1).
at Cake.Core.Tooling.Tool`1.ProcessExitCode(Int32 exitCode)
at Cake.Core.Tooling.Tool`1.Run(TSettings settings, ProcessArgumentBuilder arguments, ProcessSettings processSettings, Action`1 postAction)
at Cake.Common.Tools.DotNetCore.Tool.DotNetCoreToolRunner.Execute(FilePath projectPath, String command, ProcessArgumentBuilder arguments, DotNetCoreToolSettings settings)
at Cake.Common.Tools.DotNetCore.DotNetCoreAliases.DotNetCoreTool(ICakeContext context, FilePath projectPath, String command, ProcessArgumentBuilder arguments)
at Submission#0.DotNetCoreTool(FilePath projectPath, String command, ProcessArgumentBuilder arguments) in :line 1058
at Submission#0.<>b__0_0() in Z:\Teamcity\Work\3aedfc86eaf25d80\scripts\Package.cake:line 92
at Cake.Core.CakeTaskBuilderExtensions.<>c__DisplayClass32_0.b__0(ICakeContext x)
at Cake.Core.CakeTask.d__43.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.DefaultExecutionStrategy.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.CakeEngine.d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Cake.Core.CakeEngine.d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Cake.Core.CakeEngine.d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.CakeEngine.d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Cake.Core.CakeEngine.d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Scripting.BuildScriptHost.d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.Scripting.ScriptHost.RunTarget(String target)
at Submission#0.<>d__0.MoveNext() in Z:\Teamcity\Work\3aedfc86eaf25d80\scripts\build.cake:line 109
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.d__9`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.Scripting.Script`1.d__21.MoveNext()<---
```
## Steps to Reproduce (for bugs)
```
#module "nuget:?package=Cake.DotNetTool.Module&version=0.4.0"
#tool dotnet:?package=Amazon.Lambda.Tools&version=4.0.0&global

DotNetCoreTool(projectPath: projectPath, command: "lambda", arguments: "package");
```

## Context
I'm unable to use this module to manage my global tools on our build server

## Your Environment
```

```

Contributor guide

Open the contributing guide

Research direction

Start with the Cake.DotNetTool.Module 0.4.0 setup and the DotNetCoreTool call shown in the reproduction, then compare how Cake 0.37.0 invokes dotnet with how the module installs global tools. Reproduce the Amazon.Lambda.Tools example and consider the issue resolved when the installed tool is found and `dotnet lambda package` succeeds using the same dotnet CLI version.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system, cli, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.