Cannot purge deployment directory for Windows Service using Octopus Template

hello,

I am deploying a Windows Service project through Octopus. My Octopus is 3.2.11. The target server is Windows Server 2008 R2.

I use template come with Octopus to install the windows service. The template should take care of stopping service, purging old files, copying new files and installing and starting new window service.

But I got access denial to purge old files. Here is the error message. Seems the Octopus template not working for my project.

Does anyone run in same problem as I did? Thanks a lot if you can share your solution !

The following is the error from Octopus --------------------------------------

The Batch VIN Service service already exists; it will be stopped
17:19:47Info
Stopping the Batch VIN Service service
17:19:47Info
Service Batch VIN Service stopped
17:19:47Info
Purging the directory 'c:\batchvin\win_service’
17:20:48Error
System.UnauthorizedAccessException: Access to the path ‘c:\batchvin\win_service\BatchVIN.dll’ is denied.
17:20:49Error
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
17:20:49Error
at System.IO.File.InternalDelete(String path, Boolean checkHost)
17:20:49Error
at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.DeleteFile(String path, FailureOptions options) in Y:\work\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 107
17:20:49Error
at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate1 include, FailureOptions options, CancellationToken cancel, Boolean includeTarget) in Y:\work\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 309 17:20:49Error at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate1 include, FailureOptions options) in Y:\work\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 286
17:20:49Error
at Calamari.Deployment.Conventions.CopyPackageToCustomInstallationDirectoryConvention.Install(RunningDeployment deployment) in Y:\work\14ffc968155e4956\source\Calamari\Deployment\Conventions\CopyPackageToCustomInstallationDirectoryConvention.cs:line 39
17:20:49Error
at Calamari.Deployment.ConventionProcessor.RunInstallConventions() in Y:\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 60
17:20:49Error
at Calamari.Deployment.ConventionProcessor.RunConventions() in Y:\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 28
17:20:49Error
Running rollback conventions…
17:20:49Error
System.UnauthorizedAccessException: Access to the path ‘c:\batchvin\win_service\BatchVIN.dll’ is denied.
17:20:49Error
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
17:20:49Error
at System.IO.File.InternalDelete(String path, Boolean checkHost)
17:20:49Error
at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.DeleteFile(String path, FailureOptions options) in Y:\work\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 107
17:20:49Error
at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate1 include, FailureOptions options, CancellationToken cancel, Boolean includeTarget) in Y:\work\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 309 17:20:49Error at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.PurgeDirectory(String targetDirectory, Predicate1 include, FailureOptions options) in Y:\work\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 286
17:20:49Error
at Calamari.Deployment.Conventions.CopyPackageToCustomInstallationDirectoryConvention.Install(RunningDeployment deployment) in Y:\work\14ffc968155e4956\source\Calamari\Deployment\Conventions\CopyPackageToCustomInstallationDirectoryConvention.cs:line 39
17:20:49Error
at Calamari.Deployment.ConventionProcessor.RunInstallConventions() in Y:\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 60
17:20:49Error
at Calamari.Deployment.ConventionProcessor.RunConventions() in Y:\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 50
17:20:49Error
at Calamari.Commands.DeployPackageCommand.Execute(String[] commandLineArguments) in Y:\work\14ffc968155e4956\source\Calamari\Commands\DeployPackageCommand.cs:line 109
17:20:49Error
at Calamari.Program.Execute(String[] args) in Y:\work\14ffc968155e4956\source\Calamari\Program.cs:line 38
17:20:49Fatal
The remote script failed with exit code 100

Hi Edward,

Thanks for reaching out! I’d love to help figure out what’s going on with the error:
Access to the path 'c:\batchvin\win_service\BatchVIN.dll' is denied.
This means there’s an issue with the permissions of this file, which could have been set incorrectly depending on how it was created. How was this directory created? Would you mind going in to that directory and manually check that file to see which permissions it has? Keep in mind, it could possibly be the same case for your other files as well.

Octopus only installs in its own paths unless custom installation directory is set, which is where it will purge.

I have seen this fixed in the past by simply deleting the file and redeploying. The redeploy will recreate the file automatically with the required permissions.

If that doesn’t solve it for you, would you mind sending me your build log, and also following a couple steps to get a detailed deployment log?

  1. Turn on our special variables and then create a new release (as shown in our documentation under the Write the variables to the deployment log section)

  2. Deploy that release, and send me the deployment log (See Task log tab after the deployment, as shown here)

All of that information would be great to continuing the investigation :slight_smile:

Kenny

Notice:

This issue has been closed due to inactivity. If you encounter the same or a similar issue and require help, please open a new discussion (if we asked for logs or extra details in this thread, consider including them in the new thread). If you are the creator of this thread and believe it should not be closed let us know via our support email.