download nuget packages to well-known location #11056
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
NuGet package analysis needs to download the packages to examine the dependencies. This was previously done with
$TMP
but that could result in duplicate package downloads, using extra network bandwidth as well as disk space.In the worst case scenario, the initial package would be downloaded to 2 places on disk and the updated package would be downloaded to 3. E.g., if updating
Newtonsoft.Json
from11.0.1
to13.0.1
there would be 1 copy ofNewtonsoft.Json/11.0.1
in$TMP
and 1 copy in the global package cache. There would then be 2 copies ofNewtonsoft.Json/13.0.1
in$TMP
and 1 in the global package cache. With these changes there is now only 1 copy of11.0.1
and 1 copy of13.0.1
, both in the global package cache. Assuming a similar size between different versions of the same package, we're now downloading only 40% of what we were before.The behavior now is to use this well-known global package cache location as the download location. This meant that the unit tests needed to be updated to always have their own global package cache so they didn't pollute each other. To make this more consistent, the
TemporaryDirectory
class was modified to also set the appropriateNUGET_*
environment variables. Now as long as a test or test helper hasusing var tempDirectory = new TemporaryDirectory();
that test will get its own global package cache location.