Skip to content
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

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

Closed
304NotModified opened this issue Dec 11, 2017 · 19 comments · Fixed by #272
Assignees
Labels
Milestone

Comments

@304NotModified
Copy link
Member

304NotModified commented Dec 11, 2017

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
@304NotModified 304NotModified added this to the 6.0 milestone Dec 11, 2017
@304NotModified 304NotModified 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.' Dec 11, 2017
@304NotModified
Copy link
Member Author

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?

@304NotModified 304NotModified 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.' Dec 11, 2017
@clairernovotny
Copy link
Member

clairernovotny commented Dec 11, 2017

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.

@304NotModified
Copy link
Member Author

304NotModified commented Dec 11, 2017

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

@clairernovotny
Copy link
Member

clairernovotny commented Dec 11, 2017

Here it is:
ec476eb#diff-aab7ef1f82c6b9b12128e7accb3ec08aR66

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

@clairernovotny clairernovotny self-assigned this Dec 11, 2017
@304NotModified
Copy link
Member Author

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

@304NotModified
Copy link
Member Author

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

as we only have a partial path of course

@clairernovotny
Copy link
Member

clairernovotny commented Dec 11, 2017

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.

@304NotModified
Copy link
Member Author

304NotModified commented Dec 11, 2017

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.

@304NotModified
Copy link
Member Author

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

image

@304NotModified
Copy link
Member Author

I think i'm almost there

@qgjevukaj
Copy link

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.

@clairernovotny
Copy link
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!

@delasource
Copy link

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

@clairernovotny
Copy link
Member

@genyx can you share a repro?

@delasource
Copy link

delasource commented Jan 25, 2018

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)

@clairernovotny
Copy link
Member

Thanks, should be fixed in #325

@delasource
Copy link

Yes, that fixed it for me. thanks

@WspDev
Copy link

WspDev commented Feb 13, 2018

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]

@ebicoglu
Copy link

ebicoglu commented Apr 4, 2020

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 {} }

Goosemaner pushed a commit to Goosemaner/EFCore-Bulk-Extensions that referenced this issue Jun 15, 2022
Problem:
When you install Microsoft.EntityFrameworkCore.Sqlite 3.1.0 you can see dlls without modify date. It cause to "The DateTimeOffset specified cannot be converted into a Zip file timestamp" when you try to pack my program.
Solution:
Update lib version

related problem
NuGetPackageExplorer/NuGetPackageExplorer#269
OrchardCMS/OrchardCore#4477
NuGet/Home#7001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
6 participants