You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NuGet do not honor time-stamps when unpacking nupkg files #420
NuGet uses the current time when unpacking nupkg files, instead of time-stamps stored in the ZIP files.
This leads to "dirty file" problems for build & deployment systems relying on time-stamps for figuring out which header/lib/dll files have changed. An example of this is robocopy-based SW deployment that only replaces new/modified files.
Steps to reproduce:
With NuGet command-line: "NuGet.exe install zlib" (package found on nuget.org), or
Create a Visual Studio 2013 C++ project. Add NuGet dependency to "zlib" and build project.
Verify that unpacked *.h, *.lib & *.dll files are time-stamped with current time instead of the time in the downloaded nupkg files.
I don't know NuGet in detail, but my gut feeling is that the problem is caused by ZipArchiveExtensions.cs and PackageHelper.cs using entryStream.CopyTo(targetStream) and inputStream.CopyToAsync(outputStream) instead of ZipFileExtensions.ExtractToFile(entry, targetFile) for extracting files.
C:\Users\Fredrik\Desktop\NuGetTimeStamp-Reproducer>nuget
NuGet Version: 3.4.0.348
usage: NuGet <command> [args] [options]
Type 'NuGet help <command>' for help on a specific command.
...
This was very strange indeed. I've already tried to clean all NuGet caches under both "AppData" and ".nuget". Also, nuget.exe is not found elsewhere in my PATH.
This behavior definitely causes problems when converting from source-controlled references to Nuget-controlled references. I have not tested, but I suspect that this breaks at build time in general. If I build at time X, then restore Nuget package to a build from time X-100, then build again, I expect any projects dependent on the package to be rebuilt. Because (X-100) < X, they will not.
IMO, Nuget should use the same timestamp behavior as source control. TFS and P4 necessarily and correctly set file timestamps at sync time by default.
Yes, the timestamp preserving behavior causes incremental build issues when I need revert to an older package.
Should be an option to set like in P4 git etc.
Activity
forderud commentedon Apr 14, 2015
I don't know NuGet in detail, but my gut feeling is that the problem is caused by ZipArchiveExtensions.cs and PackageHelper.cs using entryStream.CopyTo(targetStream) and inputStream.CopyToAsync(outputStream) instead of ZipFileExtensions.ExtractToFile(entry, targetFile) for extracting files.
33 remaining items
alpaix commentedon Jan 5, 2016
Got the same build 3.4.0.348, followed @forderud steps, didn't repro.
Can you run "nuget" command with no args to confirm build version is the same?
forderud commentedon Jan 6, 2016
This was very strange indeed. I've already tried to clean all NuGet caches under both "AppData" and ".nuget". Also, nuget.exe is not found elsewhere in my PATH.
alpaix commentedon Jan 6, 2016
Okay, repro'd when forced v3 source:
Looking into this...
alpaix commentedon Jan 6, 2016
Found yet another scenario of package extractor reading file from a cache and writing back as a FileStream, here https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Packaging/PackageExtractor.cs#L127
Obviously this technique doesn't maintain original file attributes. Will work on fixing this.
forderud commentedon Jan 14, 2016
Fix now verified with VS2015. Thank you very much for all your help @alpaix.
chipplyman commentedon Jun 6, 2018
Is this really the right behavior?
This behavior definitely causes problems when converting from source-controlled references to Nuget-controlled references. I have not tested, but I suspect that this breaks at build time in general. If I build at time X, then restore Nuget package to a build from time X-100, then build again, I expect any projects dependent on the package to be rebuilt. Because (X-100) < X, they will not.
IMO, Nuget should use the same timestamp behavior as source control. TFS and P4 necessarily and correctly set file timestamps at sync time by default.
jonnyyu commentedon Sep 25, 2019
Yes, the timestamp preserving behavior causes incremental build issues when I need revert to an older package.
Should be an option to set like in P4 git etc.