Repository navigation
Description
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
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
After fix (PR is in review)
Now this file modified in 1959 after packing looks like this:




Activity
dtivel commentedon Dec 7, 2018
The
ZipArchiveEntry.LastWriteTimesetter enforces a min and max value. This behavior is documented.A NuGet solution could be:
LastWriteTimeto the min value.LastWriteTimeto the max value.There is precedence for this approach.
bobbwhy commentedon Jan 9, 2019
I ran across this issue on a Mac OS 10.14 running dotnet 2.2 and nuget 4.8.
My windows and linux machines do NOT have this issue.
can anyone tell me how to do a work around please?
OR at least where is the ZipArchiveEntry.LastWriteTime located?
Is it project wide? system wide?
thank you.
Zukka commentedon Mar 21, 2019
There is a fix for this problem?
mfkl commentedon Mar 21, 2019
Also running into this. Modified date looks like
30 November 1979, 00:00:00Zukka commentedon Mar 22, 2019
Thanks to my colleague Federico for the workaround:

1- Check if there is one or more files with date like 01/01/xxxx 00:00
2 - with Total Commander or other tools change the date value, for example in my fix I changed to 01/01/2018.
With Total Commander, select the file, then select menu File-Change Attribute...
mfkl commentedon Mar 22, 2019
That's a workaround for the bug, not a bugfix :) Both
7zandnugetneed a fix.Zukka commentedon Mar 22, 2019
Updated the comment. From fix to workaround ;)
per-samuelsson commentedon Jun 17, 2019
Also hit by this. Running simple
dotnet packon a project file with<PackAsATool>being set, and on .NET Core 3.0 Preview.Here's the environment:
fix: disable deterministic NuGet packaging which causes failures for …
fix: disable deterministic NuGet packaging which causes failures for …
fix: disable deterministic NuGet packaging which causes failures for …
51 remaining items
Fix dll timestamps before packaging on Windows
Fix dll timestamps before packaging on Windows
tobias-klein commentedon Sep 22, 2020
I would appreciate a fix of this issue. It's currently breaking the Windows build of Ezra Project.
mbre777 commentedon Oct 14, 2020
Still happening - please fix this as it's breaking my CI.
erdembayar commentedon Nov 13, 2020
I'm interested in this one as my first 'nuget pack' challenge during "Customer sprint".
Removed workaround for the fixed issue NuGet/Home#7001.
Fix dotnet pack error with Sqlite package