Example code:
string publishPath = "./publishDir";
string buildOutput = "./Release";
Task("Build-Example")
.Does(()=>
{
DotNetCorePublishSettings settings = new DotNetCorePublishSettings()
{
Configuration = configuration,
NoDependencies = false,
NoRestore = false,
OutputDirectory = publishPath,
MSBuildSettings = new DotNetCoreMSBuildSettings()
};
CleanDirectory(publishPath);
DotNetCorePublish("../src/ExampleAspnetCore31.csproj", settings);
Zip(publishPath, $"{buildOutput}/ExampleAspnetCore31.zip");
})
.Finally(() =>
{
DeleteDirectory(publishPath, new DeleteDirectorySettings()
{
Recursive = true,
Force = true
});
});
Error: System.AggregateException: One or more errors occurred. ---> 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 Cake.Common.IO.Zipper.Zip(DirectoryPath rootPath, FilePath outputPath, IEnumerable`1 paths)
at Submission#0.Zip(DirectoryPath rootPath, FilePath outputPath) in :line 2423
at Submission#0.<<Initialize>>b__0_6() in D:\Dev\QES_Portal\QESPortal\build\build.cake:line 158
at Cake.Core.CakeTaskBuilderExtensions.<>c__DisplayClass32_0.<Does>b__0(ICakeContext x)
at Cake.Core.CakeTask.<Execute>d__43.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.DefaultExecutionStrategy.<ExecuteAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.CakeEngine.<ExecuteTaskAsync>d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Cake.Core.CakeEngine.<ExecuteTaskAsync>d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Cake.Core.CakeEngine.<ExecuteTaskAsync>d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.CakeEngine.<RunTask>d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Cake.Core.CakeEngine.<RunTargetAsync>d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Scripting.BuildScriptHost.<RunTargetAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.Scripting.ScriptHost.RunTarget(String target)
at Submission#0.<<Initialize>>d__0.MoveNext() in D:\Dev\QES_Portal\QESPortal\build\build.cake:line 659
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.<RunSubmissionsAsync>d__9`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.Scripting.Script`1.<RunSubmissionsAsync>d__21.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Cake.Scripting.Roslyn.RoslynScriptSession.Execute(Script script)
at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments)
at Cake.Commands.BuildCommand.Execute(CakeOptions options)
at Cake.CakeApplication.Run(CakeOptions options)
at Cake.Program.Main()
---> (Inner Exception #0) 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 Cake.Common.IO.Zipper.Zip(DirectoryPath rootPath, FilePath outputPath, IEnumerable`1 paths)
at Submission#0.Zip(DirectoryPath rootPath, FilePath outputPath) in :line 2423
at Submission#0.<<Initialize>>b__0_6() in D:\Dev\QES_Portal\QESPortal\build\build.cake:line 158
at Cake.Core.CakeTaskBuilderExtensions.<>c__DisplayClass32_0.<Does>b__0(ICakeContext x)
at Cake.Core.CakeTask.<Execute>d__43.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.DefaultExecutionStrategy.<ExecuteAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.CakeEngine.<ExecuteTaskAsync>d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Cake.Core.CakeEngine.<ExecuteTaskAsync>d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Cake.Core.CakeEngine.<ExecuteTaskAsync>d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.CakeEngine.<RunTask>d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Cake.Core.CakeEngine.<RunTargetAsync>d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Scripting.BuildScriptHost.<RunTargetAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Cake.Core.Scripting.ScriptHost.RunTarget(String target)
at Submission#0.<<Initialize>>d__0.MoveNext() in D:\Dev\QES_Portal\QESPortal\build\build.cake:line 659
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.<RunSubmissionsAsync>d__9`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.CodeAnalysis.Scripting.Script`1.<RunSubmissionsAsync>d__21.MoveNext()<---
Simmilar problem https://github.com/OrchardCMS/OrchardCore/issues/4477.
// ...
var now = DateTime.UtcNow;
foreach(var file in GetFiles($"{publishPath}/**/*.*"))
{
System.IO.File.SetLastWriteTimeUtc(file.FullPath, now);
}
Zip(publishPath, $"{buildOutput}/ExampleAspnetCore31.zip");
Ok, this would seem to be because of an issue with source files, but ideally, Cake shouldn't cause an exception here.
I'll submit a fix for this shortly.
:tada: This issue has been resolved in version v0.38.3 :tada:
The release is available on:
Your GitReleaseManager bot :package::rocket:
I'm still getting this error when running 0.38.4. When I use the workaround detailed in this issue the issue is resolved.
Do you have an example zip file that is causing this problem?
I believe these are the files causing the problems.
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 12/31/1979 11:00 PM 20344 Microsoft.Extensions.Caching.Abstractions.dll
-a---- 12/31/1979 11:00 PM 17272 Microsoft.Extensions.Caching.Memory.dll
-a---- 12/31/1979 11:00 PM 16248 Microsoft.Extensions.Configuration.Abstractions.dll
-a---- 12/31/1979 11:00 PM 15224 Microsoft.Extensions.Configuration.Binder.dll
-a---- 12/31/1979 11:00 PM 15736 Microsoft.Extensions.Configuration.CommandLine.dll
-a---- 12/31/1979 11:00 PM 18808 Microsoft.Extensions.Configuration.dll
-a---- 12/31/1979 11:00 PM 15224 Microsoft.Extensions.Configuration.EnvironmentVariables.dll
-a---- 12/31/1979 11:00 PM 16760 Microsoft.Extensions.Configuration.FileExtensions.dll
-a---- 12/31/1979 11:00 PM 15736 Microsoft.Extensions.Configuration.Ini.dll
-a---- 12/31/1979 11:00 PM 15736 Microsoft.Extensions.Configuration.Json.dll
-a---- 12/31/1979 11:00 PM 15736 Microsoft.Extensions.Configuration.KeyPerFile.dll
-a---- 12/31/1979 11:00 PM 15224 Microsoft.Extensions.Configuration.UserSecrets.dll
-a---- 12/31/1979 11:00 PM 16248 Microsoft.Extensions.Configuration.Xml.dll
-a---- 12/31/1979 11:00 PM 20344 Microsoft.Extensions.DependencyInjection.Abstractions.dll
-a---- 12/31/1979 11:00 PM 16760 Microsoft.Extensions.DependencyInjection.dll
-a---- 12/31/1979 11:00 PM 17272 Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.dll
-a---- 12/31/1979 11:00 PM 17784 Microsoft.Extensions.Diagnostics.HealthChecks.dll
-a---- 12/31/1979 11:00 PM 16248 Microsoft.Extensions.FileProviders.Abstractions.dll
-a---- 12/31/1979 11:00 PM 15224 Microsoft.Extensions.FileProviders.Composite.dll
-a---- 12/31/1979 11:00 PM 15736 Microsoft.Extensions.FileProviders.Embedded.dll
-a---- 12/31/1979 11:00 PM 17784 Microsoft.Extensions.FileProviders.Physical.dll
-a---- 12/31/1979 11:00 PM 20856 Microsoft.Extensions.FileSystemGlobbing.dll
-a---- 12/31/1979 11:00 PM 19832 Microsoft.Extensions.Hosting.Abstractions.dll
-a---- 12/31/1979 11:00 PM 18808 Microsoft.Extensions.Hosting.dll
-a---- 12/31/1979 11:00 PM 18808 Microsoft.Extensions.Http.dll
-a---- 12/31/1979 11:00 PM 16248 Microsoft.Extensions.Localization.Abstractions.dll
-a---- 12/31/1979 11:00 PM 18296 Microsoft.Extensions.Localization.dll
-a---- 12/31/1979 11:00 PM 19832 Microsoft.Extensions.Logging.Abstractions.dll
-a---- 12/31/1979 11:00 PM 15736 Microsoft.Extensions.Logging.Configuration.dll
-a---- 12/31/1979 11:00 PM 15736 Microsoft.Extensions.Logging.Console.dll
-a---- 12/31/1979 11:00 PM 14712 Microsoft.Extensions.Logging.Debug.dll
-a---- 12/31/1979 11:00 PM 17784 Microsoft.Extensions.Logging.dll
-a---- 12/31/1979 11:00 PM 15736 Microsoft.Extensions.Logging.EventLog.dll
-a---- 12/31/1979 11:00 PM 15224 Microsoft.Extensions.Logging.EventSource.dll
-a---- 12/31/1979 11:00 PM 15224 Microsoft.Extensions.Logging.TraceSource.dll
-a---- 12/31/1979 11:00 PM 16248 Microsoft.Extensions.ObjectPool.dll
-a---- 12/31/1979 11:00 PM 16248 Microsoft.Extensions.Options.ConfigurationExtensions.dll
-a---- 12/31/1979 11:00 PM 14712 Microsoft.Extensions.Options.DataAnnotations.dll
-a---- 12/31/1979 11:00 PM 27512 Microsoft.Extensions.Options.dll
-a---- 12/31/1979 11:00 PM 22392 Microsoft.Extensions.Primitives.dll
-a---- 12/31/1979 11:00 PM 16760 Microsoft.Extensions.WebEncoders.dll
-a---- 12/31/1979 11:00 PM 17784 Microsoft.JSInterop.dll
@Sobieck wonder if it's a time zone issue, could you please open an new issue with what Cake.exe --version outputs, which OS your running and what diagnostic output gives.
Will do. Thanks for your help. I love the work you all do.
Will do. Thanks for your help. I love the work you all do.
Thanks @Sobieck, please mention in issue which time zone is local for you.