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

Viewed 2129

When I want to pack my library as a NuGet package, I get the below error

The DateTimeOffset specified cannot be converted into a Zip file timestamp

I'm using the below command to pack my project:

dotnet msbuild /t:pack /p:Configuration=Release /p:SourceLinkCreate=true
3 Answers

The problem is; some DLL files have invalid dates for a zip file (like 31/12/1979). You can overcome this issue by updating all the invalid DLL files modification date. Here's the Powershell script that updates all the invalid DLLs.

gci -path "C:\" -rec -file *.dll | Where-Object {$_.LastWriteTime -lt (Get-Date).AddYears(-20)} | %  { try { $_.LastWriteTime = '01/01/2020 00:00:00' } catch {} }

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:\.

I made a console app to fix invalid dates in a drive (cross-platform). It sets the LastModificationDate to 01/01/2000. You can just run it without any arguments. It will run in all your drives. Also you can specify a directory to search in.

Source-code on GitHub:

Usage:

FileBulkDateChanger.exe

or

FileBulkDateChanger.exe C:\

For MAC/Linux,

dotnet FileBulkDateChanger.dll

Run this tool and forget about this issue :)

Related