-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Floating package references don't get updated because of the no-op and http caches #7198
Comments
current expire time for http-cache is 30 mins. we can consider either short this time or create a feature like no-cache flag |
@zhili1208 I'm not seeing new packages restored after 30 minutes, so either the 30 minute expiration is not operating as expected or is unrelated to this issue. In a recent case of this happening, I had a build server fail to restore a newer version that was published 4 days earlier. I've also just reproduced this in a project where I ran |
@mpetito Could you check the Fiddler log, when you repro the issue, does nuget send http request to VSTS? also does VSTS return correct version information? I saw a very similar issue which is related to VSTS months ago. So please check this first |
@zhili1208 In Fiddler, when running I do see the expected HTTP requests to the feed if I run |
As more evidence that caching is not working as expected, the next day (16 hours later), If I download the latest nuget.exe cli (4.7.1) and run |
@zhili1208 Is this an issue I should raise with the dotnet cli team? It seems like this issue is miscategorized as the expected behavior for the http cache is not working when nuget is invoked via msbuild. |
thanks, it looks like a nuget bug, I will mark it as bug |
Do we have a repro here @zhili1208, @mpetito? list and restore use different endpoints, so it's not a perfect analogy to compare those 2. Does restore work on any other machine consistently? |
@nkolev92 I've reproduced / witnessed this behavior on four workstations and a build server now. Each have installed latest versions of .net sdk and Visual Studio. However, each are also building the same projects, so it could be something wrong with the project setup. I've thought about how best to provide a working repro but it's a little tricky because:
I will try to recreate the environment for testing this if it's useful. |
Thanks @mpetito |
@nkolev92 @zhili1208 I've put together a sample repository at https://github.com/mpetito/RestoreTest which reproduces this issue. Instructions are included there, and note the api key included is only valid for the package I was successful in reproducing the issue using new projects for both the nuget package and the referencing project publishing to nuget.org. I also happened to update to Visual Studio 15.8.0 which did not resolve the issue (I'm not sure if this update changed my versions of msbuild or nuget). |
@nkolev92 If I understand correctly then, the workarounds are:
I get why this behavior makes sense as you're trying to minimize network calls during restore. However, I'll probably re-evaluate the usage of floating versions for my particular use-case or minimally force --no-cache restores on build servers. In this regard, disabling the cache per feed using NuGet.config would be a useful feature even if used solely for build servers. |
My team has also run into this exact scenario. We've had to update our build scripts to use Even after the 30 minutes has expired, new versions are not pulled. |
@mpetito
@anangaur has been looking into improving this behavior. It's likely that soon enough we have an explicit option to force the reevaluation, rather than relying on rebuild.
Can you clarify what you mean by
Both no-op and the http caching strategy are erring on the side of performance as in a lot of cases, this led to too many network calls that made nuget feel sluggish. We understand that this leads to the situations that we've called out in #5445 and what you're articulating. I'll amend this issue a bit to reflect that.
After 30 minutes you should be able to run --force, no need to to do --no-cache. |
@nkolev92 in my informal testing comparing the timing output between --no-cache and --force, without waiting for the 30 min http-cache expiry, I found the timings to be nearly identical (within tens of milliseconds). In both cases the restore time was about 2.3s for the project I tested. This could have been due to my connection speed, and other restore work significantly outweighing the extra network call for --no-cache. |
Ah, that's what you meant :) Yeah, it's influenced by the connection speed and the fact that most of the packages don't need updated, so there's likely only a few package downloads happening. |
Do we have any news on the way to go for this? Can't we have at least a way (which can be automated) to disable/ignore the cache mechanism altogether in certain cases? |
@zhili1208 @nkolev92 Would you accept a PR that tries to fix/enable disabling the cache on rebuild/explicitly? |
@nkolev92 OK, but I am thinking of the scenario that if I want to explicitly do a rebuild ignoring case, I should be able to do it, without having to wait X minutes for the cache to expire. Maybe I am missing something? |
There are multiple caching strategies in place. However, I'd be in favor of adding switches to do that. //cc @anangaur fyi. |
Don’t we already have a —no-cache switch already? |
We do. The VS experience needs some thought. |
The use case is pretty simple: say, I merged something on a dependent library, and in my main project, where I reference the package via floating reference, I want to do a rebuild now, taking into account the newly deployed version. How can I do that from:
|
Any update on this? As @mpetito has suggested before, making a feed non-cacheable would make more sense for floating package references because, in my opinion, this feature is mostly used for packages which get lots of update in a day and is published to a different feed. In that scenario, I shouldn't wait for 30 minutes to download latest version of package.
@nkolev92 is there an equivalent of |
NuGet.exe has a |
Then, can we say following documents are outdated? |
Seems like they are. |
@nkolev92 don't agree with the assessment that it's a small amount of use cases, anyone coming from maven/java has been relying on this type of behaviour with -SNAPSHOT for the last decade. Any time you are working with a shared library and making mods on it that you want to immediately use on your main project this type of flow is vital to rapid dev. |
Details about Problem
I have a .NET Core project which references nuget packages published on a private feed in Visual Studio Team Services. These references use floating versions, such as:
During the first restore operation using
dotnet restore
, the latest patch version is retrieved from the nuget feed as expected. However, if a new patch version is published, subsequent restores on the same machine will never see the update unless I explicitly rundotnet restore --no-cache
or alternatively rundotnet nuget locals http-cache --clear
.Other suggested things
I understand there is an http-cache in use, where restore operations may use a cached list of versions for each package. I can see this cache and the stale version list on disk which explains why
dotnet restore
isn't restoring the new version.However, it seems like this makes the usage of floating package versions confusing. Even if I force the restore of a newer version locally using
--no-cache
, other developers or build servers may be stuck with an older version. Is the intention really that the http-cache should never expire, and new versions will never be automatically restored unless explicitly called with--no-cache
?My expectation is that the http-cache for the version list should be short lived, and
dotnet restore
(performed explicitly or as part of a build) would eventually see new versions for floating package versions. Note that the http-cache also does not appear to respect the HTTP headers returned by the feed, as in Fiddler I can see that VSTS returns no-cache directives on the nuget feed responses.If a short-lived cache is not advisable for some other reasons, then I would request a feature that allows disabling the cache per feed in nuget.config. This way the
--no-cache
flag might be automatically applied for private package feeds as appropriate.NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe):
NuGet version: 4.6.0
dotnet.exe --version: 2.1.302
VS version: Visual Studio 2017 15.7.6
OS version: Windows 10
Worked before? If so, with which NuGet version: Not sure.
The text was updated successfully, but these errors were encountered: