Skip to content

Crash on opening push dialog/save: The DateTimeOffset specified cannot be converted into a Zip file timestamp.' #269

Closed

Description

@304NotModified

Type (choose one):

  • Bug

NPE version: (e.g. 3.12) 3.25

Installed from: source - 6fb8f2638206af4e2a98ffcc71f450ef3636d1b3

In case of a BUG:

  • What is the current result? exception
  • What is the expected result? showing popup for push
  • Please post full exception details in case of an Exception (message, stacktrace, inner exceptions)
System.ArgumentOutOfRangeException
  HResult=0x80131502
  Message=The DateTimeOffset specified cannot be converted into a Zip file timestamp.
Parameter name: value
  Source=System.IO.Compression
  StackTrace:
   at System.IO.Compression.ZipArchiveEntry.set_LastWriteTime(DateTimeOffset value)
   at NuGet.Packaging.PackageBuilder.CreatePart(ZipArchive package, String path, Stream sourceStream, DateTimeOffset lastWriteTime)
   at NuGet.Packaging.PackageBuilder.WriteFiles(ZipArchive package, HashSet`1 filesWithoutExtensions)
   at NuGet.Packaging.PackageBuilder.Save(Stream stream)
   at PackageExplorerViewModel.PackageHelper.SavePackage(IPackageMetadata packageMetadata, IEnumerable`1 files, String targetFilePath, Boolean useTempFile) in X:\_github\NuGetPackageExplorer\PackageViewModel\Utilities\PackageHelper.cs:line 34

  • Are there any work arrounds? no
  • Is there a version in which it did worked? not checked
  • Is there a package on Nuget.org which shows the bug?
    Nlog 4.4.12

steps:
image

image

extra info:

  • current culture: nl-NL
  • current ui culture: en-US

Activity

  1. added this to the milestone on Dec 11, 2017
  2. changed the title [-]Push bug: The DateTimeOffset specified cannot be converted into a Zip file timestamp.'[/-] [+]Crash on opening push dialog: The DateTimeOffset specified cannot be converted into a Zip file timestamp.'[/+] on Dec 11, 2017
  3. 304NotModified commented on Dec 11, 2017

    @304NotModified
    CollaboratorAuthor

    mmm same for save and with a new package.

    Setting current culture on en-US won't help (or maybe too late)

    @onovotny any idea?

  4. changed the title [-]Crash on opening push dialog: The DateTimeOffset specified cannot be converted into a Zip file timestamp.'[/-] [+]Crash on opening push dialog/save: The DateTimeOffset specified cannot be converted into a Zip file timestamp.'[/+] on Dec 11, 2017
  5. clairernovotny commented on Dec 11, 2017

    @clairernovotny
    Member

    Is this a localization thing? Is there a sample? What's the DateTimeOffset that's failing?

    Isn't there a new LastWriteTime on the file metadata? we could be defaulting it to minvalue, but we probably need to handle it and set it correctly.

  6. 304NotModified commented on Dec 11, 2017

    @304NotModified
    CollaboratorAuthor

    I don't know where there is a DateTimeOffset. I'm debugging it

  7. clairernovotny commented on Dec 11, 2017

    @clairernovotny
    Member

    Here it is:
    ec476eb#diff-aab7ef1f82c6b9b12128e7accb3ec08aR66

    I stubbed it out, guess we need to populate it.

  8. 304NotModified commented on Dec 11, 2017

    @304NotModified
    CollaboratorAuthor

    public DateTimeOffset LastWriteTime => DateTimeOffset.MinValue;?

    think so, seeing this call stack:

       at System.IO.Compression.ZipArchiveEntry.set_LastWriteTime(DateTimeOffset value)
       at NuGet.Packaging.PackageBuilder.CreatePart(ZipArchive package, String path, Stream sourceStream, DateTimeOffset lastWriteTime)
       at NuGet.Packaging.PackageBuilder.WriteFiles(ZipArchive package, HashSet`1 filesWithoutExtensions)
       at NuGet.Packaging.PackageBuilder.Save(Stream stream)
       at PackageExplorerViewModel.PackageHelper.SavePackage(IPackageMetadata packageMetadata, IEnumerable`1 files, String targetFilePath, Boolean useTempFile) in X:\_github\NuGetPackageExplorer\PackageViewModel\Utilities\PackageHelper.cs:line 43
    
  9. 304NotModified commented on Dec 11, 2017

    @304NotModified
    CollaboratorAuthor

    any idea if we could use File.LastAccessTime(path) ?

    as we only have a partial path of course

  10. clairernovotny commented on Dec 11, 2017

    @clairernovotny
    Member

    I think that should work long as that doesn't throw. AFAIK, the base is set to the directory the nuspec file is in. NPE doesn't support specifying an alternate base directory.

  11. 304NotModified commented on Dec 11, 2017

    @304NotModified
    CollaboratorAuthor

    it gives also minValue.

    I could read the content of the file (e.g. dll) as stream in

    _streamFactory = () => reader.GetStream(path);

    but that doesn't have a lastWriteTime of course.

  12. 304NotModified commented on Dec 11, 2017

    @304NotModified
    CollaboratorAuthor

    ah found it, but now thinking where this code should be added

    image

  13. 304NotModified commented on Dec 11, 2017

    @304NotModified
    CollaboratorAuthor

    I think i'm almost there

  14. qgjevukaj commented on Dec 30, 2017

    @qgjevukaj

    304NotModified + this still appears to be an issue when creating a new package with several files and folders. Upon saving (as) the program will hang and eventually respond with "DateTimeOffset specified cannot be converted into a zip file timestamp. It seems to work fine with a smaller amount of files and/or saving the initial package with a smaller amount of files and adding more in after each save. I have an older stable release in my repository which does not report this issue.

  15. clairernovotny commented on Dec 30, 2017

    @clairernovotny
    Member

    @ItsMrQ can you repro on the current CI version? The one that has these changes has not been in a stable release yet. Otherwise, please open a new issue with a repro.

    Thanks!

  16. delasource commented on Jan 25, 2018

    @delasource

    I can confirm that the error still happens on the new CI version. I can't use NPE anymore. It seems to have affected the whole program

  17. clairernovotny commented on Jan 25, 2018

    @clairernovotny
    Member

    @GENYX can you share a repro?

  18. delasource commented on Jan 25, 2018

    @delasource

    Unfortunally, i don't know... I start NPE (used the CI setup on the main github page) leave the metadata as default, add a lib folder, add an empty net45 folder and click save. It does not save and says the error like above.

    Latest Windows 10, .NET 4.7.1 installed (which i was trying to create a package for)

  19. clairernovotny commented on Jan 25, 2018

    @clairernovotny
    Member

    Thanks, should be fixed in #325

  20. delasource commented on Jan 25, 2018

    @delasource

    Yes, that fixed it for me. thanks

  21. WspDev commented on Feb 13, 2018

    @WspDev

    I got this issue when I had an empty folder under a net folder under lib.
    Putting files in it solved the issue.
    [Edit] Using version 4.0.9 [/Edit]

  22. ebicoglu commented on Apr 4, 2020

    @ebicoglu

    My solution:

    Run the below Powershell script.
    It sets all the invalid DLL dates to 01/01/2000.
    Change the path parameter for your computer.
    My GitHub repositories are on my C drive so I'm running this -path C:\.

    gci -path "C:\" -rec -file *.dll | Where-Object {$_.LastWriteTime -lt (Get-Date).AddYears(-20)} | %  { try { $_.LastWriteTime = '01/01/2000 00:00:00' } catch {} }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions