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

Build script caching throws after running dry-run on non-changed Cake script #3879

Closed
2 tasks done
patriksvensson opened this issue Apr 28, 2022 · 1 comment · Fixed by #3881
Closed
2 tasks done
Assignees
Labels
Projects
Milestone

Comments

@patriksvensson
Copy link
Member

patriksvensson commented Apr 28, 2022

Prerequisites

  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported

Cake runner

Cake .NET Tool

Cake version

2.2.0

Operating system

Windows

Operating system architecture

64-Bit

CI Server

No response

What are you seeing?

If I turn build caching on and run my build script, and after that dry run the same unchanged script (or vice versa), I get an exception.

What is expected?

I would expect Cake to clear the cache after a dry run (and before running a dry run), or perhaps keep track of whether a switch between dry run and non-dry run has occurred.

Steps to Reproduce

  1. Enable build script caching via a cake.config file
  2. Run dotnet cake
  3. Run dotnet cake --dryrun

Output log

Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.InvalidCastException: Unable to cast object of type 'Cake.Cli.DryRunScriptHost' to type 'Cake.Cli.BuildScriptHost'.
   at Submission#0..ctor(Object[] submissionArray)
   at Submission#0.<Factory>(Object[] submissionArray)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Cake.Infrastructure.Scripting.RoslynScriptSession.RunScriptAssembly(String assemblyPath) in C:\projects\cake\src\Cake\Infrastructure\Scripting\RoslynScriptSession.cs:line 232
   at Cake.Infrastructure.Scripting.RoslynScriptSession.Execute(Script script) in C:\projects\cake\src\Cake\Infrastructure\Scripting\RoslynScriptSession.cs:line 115
   at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath) in C:\projects\cake\src\Cake.Core\Scripting\ScriptRunner.cs:line 172
   at Cake.Features.Building.BuildFeature.RunCore(IRemainingArguments arguments, BuildFeatureSettings settings) in C:\projects\cake\src\Cake\Features\Building\BuildFeature.cs:line 99
   at Cake.Features.Building.BuildFeature.Run(IRemainingArguments arguments, BuildFeatureSettings settings) in C:\projects\cake\src\Cake\Features\Building\BuildFeature.cs:line 49
   at Cake.Commands.DefaultCommand.Execute(CommandContext context, DefaultCommandSettings settings) in C:\projects\cake\src\Cake\Commands\DefaultCommand.cs:line 73
@patriksvensson patriksvensson added this to To do in 2.0.0 via automation Apr 28, 2022
@devlead devlead added this to the v2.3.0 milestone Apr 29, 2022
@devlead devlead self-assigned this Apr 29, 2022
devlead added a commit to devlead/cake that referenced this issue Apr 29, 2022
* Include script host in filename
* Move hash from file to filename
* fixes cake-build#3879
* fixes cake-build#3880
devlead added a commit to devlead/cake that referenced this issue Apr 29, 2022
* Include script host in the cache filename
* Move hash from file to the cache filename
* fixes cake-build#3879
* fixes cake-build#3880
devlead added a commit to devlead/cake that referenced this issue Apr 29, 2022
* Include script host in the cache filename
* Move hash from file to the cache filename
* fixes cake-build#3879
* fixes cake-build#3880
devlead added a commit to devlead/cake that referenced this issue Apr 29, 2022
* Include script host in the cache filename
* Move hash from file to the cache filename
* fixes cake-build#3879
* fixes cake-build#3880
2.0.0 automation moved this from To do to Done Apr 29, 2022
devlead added a commit that referenced this issue Apr 29, 2022
GH3879/3880: Scope cache per script host
@cake-build-bot
Copy link

🎉 This issue has been resolved in version v2.3.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
2.0.0
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants