Skip to content

NuGet pack "The DateTimeOffset specified cannot be converted into a Zip file timestamp" #7001

Description

@oskogstad

Details about Problem

Running nuget pack .nuspec fails with the message
"The DateTimeOffset specified cannot be converted into a Zip file timestamp."

It happens with nuget 4.6.2 for a .dll file that has LastWriteTime 31/12/1979 23:00:00 +00:00

image

NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe):
NuGet.exe
version (4.6.2.5055)

OS version (i.e. win10 v1607 (14393.321)):
Windows 10 v 1803 Build 17134.81

Worked before? If so, with which NuGet version:
Works with v. 4.5.1.4879

Detailed repro steps so we can see the same problem

Run nuget pack NuGetDateTimeOffsetIssue.nuspec in the attached sample project
on nuget.exe v. 4.6 or higher.

Or:
Make a class library that includes NuGet log4net.Ext.Json v. 1.2.15.14586
Run nuget spec <lib-name>
Run nuget pack <.nuspec>

Verbose Logs

~/Downloads ❯❯❯ ./nuget\(1\).exe pack -verbosity detailed C:/dev/.../authenticationhost.nuspec                                                                                          
NuGet Version: 4.6.2.5055
Attempting to build package from 'authenticationhost.nuspec'.
The DateTimeOffset specified cannot be converted into a Zip file timestamp.
Parameter name: value
System.ArgumentOutOfRangeException: The DateTimeOffset specified cannot be converted into a Zip file timestamp.
Parameter name: value
   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 NuGet.Commands.PackCommandRunner.BuildPackage(PackageBuilder builder, String outputPath)
   at NuGet.Commands.PackCommandRunner.BuildFromNuspec(String path)
   at NuGet.Commands.PackCommandRunner.BuildPackage()
   at NuGet.CommandLine.PackCommand.ExecuteCommand()
   at NuGet.CommandLine.Command.ExecuteCommandAsync()
   at NuGet.CommandLine.Command.Execute()
   at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)

Sample Project

NuGetDateTimeOffsetIssue.zip

image

After fix (PR is in review)

Input file for test:
image

Now this file modified in 1959 after packing looks like this:
image

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions