Skip to content

NuGet do not honor time-stamps when unpacking nupkg files #420

Closed

Description

@forderud

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.

Activity

  1. forderud commented on Apr 14, 2015

    @forderud
    Author

    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.

  2. added this to the 3.0.0-RTM milestone on Apr 14, 2015
  3. modified the milestones: , 3.0.0-RTM on May 21, 2015
  4. added
    Priority:3
    and removed on May 21, 2015
  5. modified the milestones: , 3.1 RTM UWP transitive support on Jun 24, 2015
  6. 33 remaining items

  7. alpaix commented on Jan 5, 2016

    @alpaix

    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?

  8. forderud commented on Jan 6, 2016

    @forderud
    Author
    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.

  9. alpaix commented on Jan 6, 2016

    @alpaix

    Okay, repro'd when forced v3 source:

     .\NuGet.exe restore NuGetTimeStamp.sln -NoCache -source https://api.nuget.org/v3/index.json -Verbosity detailed
    

    Looking into this...

  10. reopened this on Jan 6, 2016
  11. alpaix commented on Jan 6, 2016

    @alpaix

    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.

  12. forderud commented on Jan 14, 2016

    @forderud
    Author

    Fix now verified with VS2015. Thank you very much for all your help @alpaix.

  13. chipplyman commented on Jun 6, 2018

    @chipplyman

    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.

  14. jonnyyu commented on Sep 25, 2019

    @jonnyyu

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Priority:3Type:Bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions