Nuget restore and caching
After migration from packages.config to PackageReference where nuget uses a global cache how can I best speed of restore times for builds
I was thinking about putting this in my ```apveyor.yml``` file
```
# cache the nuget packages folders (PROBLEM: The project.lock.json files are renamed and moved to obj\project.assets.json)
cache:
- '%USERPROFILE%\.nuget\packages' # global‑packages
- '%LocalAppData%\NuGet\v3-cache' # http‑cache
```
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 Owen McDonnell on Sep 25, 2018 @ 05:22 PM
Are you saying that you are checking the
project.lock.json
files into source control? If you are using PackageReference, it's my understanding that you can just ignore the lock file.2 Posted by Morten Maxild on Sep 26, 2018 @ 10:57 AM
project.lock.json is dead. In .NET Core today the dotnet cli outputs obj/project.assets.json, but these files cannot be tracked by GIT, or used in cache expressions in appveyor.yml.
I am using PackageReference in old csproj and also the new SDK csproj (also beased on PackageReference nuget model). Both use the global cache, as described above.
Your documentation about caching nuget packages, only describe the old packages.config Nuget model. That is why I am asking for the best way to speed up nuget restore times on the build, if not using packages.config
Support Staff 3 Posted by Owen McDonnell on Sep 27, 2018 @ 04:11 AM
So your question is what to use as a cache dependency? What about the project file that contains the PackageReference node?
4 Posted by Morten Maxild on Oct 01, 2018 @ 12:45 PM
Can I cache the nuget global cache (%USERPROFILE%\.nuget\packages) outside the downloaded/cloned code tree?
Support Staff 5 Posted by Owen McDonnell on Oct 01, 2018 @ 04:10 PM
I agree with your answer in this thread that it doesn't make sense to declare a cache dependency on the nuget global cache folder/tree. I was simply trying to answer the question I thought you were asking ("these files cannot be... used in cache expressions in appveyor.yml").
Sure you can cache folders outside the clone directory.
Ilya Finkelshteyn closed this discussion on Dec 01, 2018 @ 09:00 PM.