Caching Submodule Packages
Hello. We are using submodules and so our appveyor.yml looks something like this (exact repo names changed so that we can leave this discussion public):
version: 1.0.{build}
install:
- ps: >-
$fileContent = "-----BEGIN RSA PRIVATE KEY-----`n"
$fileContent += $env:priv_key.Replace(' ', "`n")
$fileContent += "`n-----END RSA PRIVATE KEY-----`n"
Set-Content c:\users\appveyor\.ssh\id_rsa $fileContent
git submodule -q update --init --recursive
cache:
- packages -> **\packages.config
- util/packages -> util\**\packages.config
before_build:
- nuget restore util\Util.sln
- nuget restore Toplevel.sln
You can see we tried to cached the submodule packages. This actually works, but then the problem is that when the packages are restored the submdodule directory gets created, so then the submodule fetch fails. Here is our build log:
Build started
git clone -q git@github.com:toolwatch/toplevel.git C:\projects\toplevel
git fetch -q origin +refs/pull/154/merge:
git checkout -qf FETCH_HEAD
Restoring build cache
Restoring "packages"...OK
Restoring "util/packages"...OK
Running Install scripts
$fileContent = "-----BEGIN RSA PRIVATE KEY-----`n"
$fileContent += $env:priv_key.Replace(' ', "`n")
$fileContent += "`n-----END RSA PRIVATE KEY-----`n"
Set-Content c:\users\appveyor\.ssh\id_rsa $fileContent
git submodule -q update --init --recursive
git : fatal: destination path 'util' already exists and is not an empty directory.
At line:5 char:1
+ git submodule -q update --init --recursive
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (fatal: destinat...mpty directory.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Clone of 'git@github.com:toolwatch/util.git' into submodule path 'util' failed
Command executed with exception: Clone of 'git@github.com:toolwatch/util.git' into submodule path 'util' failed
One workaround would be if the cache restore happened after the install scripts. This would allow us to fetch our submodules, and then restore the packages into them.
Another workaround would be for appveyor to natively support fetching submodules. I know Travis does this. To be honest I haven't thought much about this, so there might be very good reasons for your approach. Just noting it as an extra complication vs. Travis.
Also, FYI, the cache restore step isn't listed here: http://www.appveyor.com/docs/build-configuration
The workaround for now is to just stop caching the submodule packages. The downside to this is that sometimes the nuget package fetch fails, of course, so we get false failed builds.
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
| ? | Show this help |
|---|---|
| ESC | Blurs the current field |
Comment Form
| r | Focus the comment reply box |
|---|---|
| ^ + ↩ | Submit the comment |
You can use Command ⌘ instead of Control ^ on Mac

Support Staff 1 Posted by Feodor Fitsner on 04 Aug, 2015 06:58 PM
Instead of caching
packagesfolder you can try caching NuGet cache:so nuget.exe will be just copying packages from there and skip downloading.
2 Posted by Craig McDonald on 05 Aug, 2015 07:26 PM
Thanks, Feodor. We'll give it a try, and I'll come update this thread in a
bit to let any future passerbys know how this work out.
Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 01:58 AM.