Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 577
Alper Ebicoglu Avatar asked Mar 03 '23 14:03

Alper Ebicoglu


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

like image 66
Alper Ebicoglu Avatar answered May 05 '23 05:05

Alper Ebicoglu