Skip to content

Improve script caching behavior #4471

Closed

Description

@GeertvanHorrik

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

latest

Operating system

Windows

Operating system architecture

x64

CI Server

N/A

What are you seeing?

We see script caching not working as we hoped. For example:

Run (according to build system): 39 seconds, but Cake logs show:

Task                          Duration            
--------------------------------------------------
Setup                         00:00:00.2121813    
Prepare                       00:00:00.2494064    
UpdateNuGet                   00:00:00.0003786    
RestorePackages               00:00:05.8670747    
Deploy                        00:00:01.2517940    
--------------------------------------------------
Total:                        00:00:07.5808350    

So theoretically 32 seconds can be shaved off.

I am currently adding logging to the script compilation (although this is on a much faster machine):

Without cache file:

Compilation took '00:00:01.5861141'

With cache file:

Loading script assembly from cache took '00:00:00.0036443'

I think this would be a nice addition to always log to the output window (I think people want to see this).

Will add more tracings and update this ticket.

What is expected?

N/A

Steps to Reproduce

N/A

Output log

No response

Activity

  1. GeertvanHorrik commented on May 15, 2025

    @GeertvanHorrik
    ContributorAuthor

    Added some more timings:

    Bootstrapping took '00:00:00'
    Reading configuration took '00:00:00.0003681'
    Loading modules took '00:00:00.0004979'
    Analyzing the script took '00:00:01.2996956'
    Installing tools took '00:00:00.4002853'
    Installing addins took '00:00:00.0942559'
    Create session took '00:00:00.0005095'
    Loading references took '00:00:00.4481680'
    Loading aliases took '00:00:00.2436325'
    Importing namespaces took '00:00:00.0009081'
    
  2. GeertvanHorrik commented on May 15, 2025

    @GeertvanHorrik
    ContributorAuthor

    I think I found a useful pointer why caching is not working. The contents contain full path names:

    #line 1 "C:/Source/Project/build.cake"
    

    But... on (most) build agents, it will be a random, unique directory:

    #line 1 "C:/CI_WS/12345/Project/build.cake"
    

    I think using simplified paths for script cache comparison could work here, doing some additional testing.

  3. added a commit that references this issue on May 15, 2025
  4. gep13 commented on May 20, 2025

    @gep13
    Member

    @GeertvanHorrik just to make sure that I have understood this correctly...

    Are you saying that you are using the build script cache, across different build agents? Which is why you are seeing the path to the scripts be different in each case? How are you keeping the build script cache "alive" between build executions? Are you using some sort of caching at the build agent level?

    Just want to make sure that I am understanding the need for the change here.

  5. GeertvanHorrik commented on May 20, 2025

    @GeertvanHorrik
    ContributorAuthor

    No, not different build agents. Different builds, where the build agent assigns a different folder (unique to the build) every time. This is to introduce caching on the build agent level (or, for that matter, even on local builds since we use exactly the same scripts to do local nuget packags on dev machines).

  6. gep13 commented on May 20, 2025

    @gep13
    Member

    Gotcha! Thank you for the clarification, this helps!

  7. added this to the v5.1.0 milestone on May 24, 2025
  8. added a commit that references this issue on May 25, 2025
  9. github-actions commented on Oct 4, 2025

    @github-actions

    🎉 This issue has been resolved in version v5.1.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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions