Cache step doesn't save and restore empty directories

I have a Xamarin build workflow and I try to cache bin and obj directories for both Android and iOS projects. Unfortunately, while trying to build Android project I encounter the error stating that some directories in obj folder are missing. These directories are empty after build but are required by msbuild tasks for some reason.

I verified this situation by downloading the cache archive and checking through files. Screenshot shows some of the differences between actual build output (bottom) and cached files (top). Directories like 0 or 1 contain empty folders.

Is there any way to cache all the directories even if they’re empty? Now it takes more than 30 min to build Android and iOS projects and with cache enabled, I presume, it would take less than 15.

This is my cache:push step:

  finish:
    steps:
    - cache-push@2.1.1:
        inputs:
        - cache_paths: |-
            src/Project.Droid/bin/
            src/Project.iOS/bin/
            src/Project.Core/bin/
            src/Project.Droid/obj/
            src/Project.iOS/obj/
            src/Project.Core/obj/
            $HOME/.local/share/Xamarin/
            $HOME/.nuget/packages/

Hy there👋

I think we don’t cache empty folders by design, my workaround would be a script that creates these for you, it wold run in line 3-4 secs and this problem would be nonexistent.
something like mkdir src/Project.iOS/obj/Test/Ip/0 src/Project.iOS/obj/Test/Ip/1

Thank you for your answer.
I’ll try to determine what folders are missing but it seems to be really prone to changes in used libraries etc. I’ll let you know about the outcome.

Just out of curiosity, would it be even possible to enable saving empty directories on your side?

Here is my update. Naive for loop in bash creating all the missing folders solved the problem. Thank you for your suggestion @fehersanyi-bitrise :slight_smile:

1 Like

Great, I’m glad it works now!:tada:

I guess caching empty folders would not be a logical step with only one issue reported because it :confused:

Yes, you’re probably right.

Fortunately only one step in MSBuild workflow required these folders to exist, so fix was straightforward. It seems that it’s rather problem on Microsoft side that the build fails when part of path to empty directory does not exist :confused:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.