We’ve a minor issue where under certain circumstances our app creates a number of folders and files and the path becomes too long. On the subsequent deployment, it causes Octopus to fail to purge the folder when deploying a package:
09:15:46 Info | Purging the directory 'E:\WebApp'
09:16:26 Error | System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
09:16:26 Error | at System.IO.PathHelper.GetFullPathName()
09:16:26 Error | at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
09:16:26 Error | at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath)
09:16:26 Error | at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath)
09:16:26 Error | at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
09:16:26 Error | at System.IO.FileSystemInfo.get_FullName()
09:16:26 Error | at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
09:16:26 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate`1 exclude, FailureOptions options, CancellationToken cancel, Boolean includeTarget) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 373
09:16:26 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate`1 exclude, FailureOptions options, CancellationToken cancel, Boolean includeTarget) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 403
09:16:26 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate`1 exclude, FailureOptions options, CancellationToken cancel, Boolean includeTarget) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 403
09:16:26 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate`1 exclude, FailureOptions options, CancellationToken cancel, Boolean includeTarget) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 403
09:16:26 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate`1 exclude, FailureOptions options, CancellationToken cancel, Boolean includeTarget) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 403
09:16:26 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate`1 exclude, FailureOptions options, CancellationToken cancel, Boolean includeTarget) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 403
09:16:26 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate`1 exclude, FailureOptions options, CancellationToken cancel, Boolean includeTarget) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 403
09:16:26 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate`1 exclude, FailureOptions options, CancellationToken cancel, Boolean includeTarget) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 403
09:16:26 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate`1 exclude, FailureOptions options, CancellationToken cancel, Boolean includeTarget) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 403
09:16:26 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate`1 exclude, FailureOptions options, CancellationToken cancel, Boolean includeTarget) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 403
09:16:26 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate`1 exclude, FailureOptions options, CancellationToken cancel, Boolean includeTarget) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 403
09:16:26 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate`1 exclude, FailureOptions options, CancellationToken cancel, Boolean includeTarget) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 403
09:16:26 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate`1 exclude, FailureOptions options, CancellationToken cancel, Boolean includeTarget) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 403
09:16:26 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate`1 exclude, FailureOptions options, CancellationToken cancel, Boolean includeTarget) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 403
09:16:26 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate`1 exclude, FailureOptions options, CancellationToken cancel, Boolean includeTarget) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 403
09:16:26 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate`1 exclude, FailureOptions options, CancellationToken cancel, Boolean includeTarget) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 403
09:16:26 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate`1 exclude, FailureOptions options) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 361
09:16:26 Error | at Calamari.Deployment.Conventions.CopyPackageToCustomInstallationDirectoryConvention.Install(RunningDeployment deployment) in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Deployment\Conventions\CopyPackageToCustomInstallationDirectoryConvention.cs:line 62
09:16:26 Error | at Calamari.Deployment.ConventionProcessor.RunInstallConventions() in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 60
09:16:26 Error | at Calamari.Deployment.ConventionProcessor.RunConventions() in Z:\buildAgent\workDir\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 28
09:16:26 Error | Running rollback conventions...
Workaround is to simply delete the contents of the folder manually and carry on.
Octopus Server version 3.11.4
Calamari version 3.7.5