3.3 Beta - Permissions issue when deploying ASP.NET 5 app

I have a zipped Asp.Net 5 app on my Octo feed and I have created the package within the guidelines provided here: http://docs.octopus.com/display/OD/Supported+Packages

I followed the instructions to set up my package deployment step here:
http://docs.octopus.com/display/OD/Deploying+ASP.NET+Core+Web+Applications

… But when I run the deployment I get a permissions error on the first item to unzip (the logs directory) like this:

Deploying package 'C:\Octopus\Files\my.project.2016.02.574.zip-f685eec4-a141-4950-9751-3354ace7f524' to machine 'https://10.12.5.15:10933/' 14:05:27Info Deploying package: C:\Octopus\Files\my.project.2016.02.574.zip-f685eec4-a141-4950-9751-3354ace7f524 System.UnauthorizedAccessException: Access to the path 'C:\Octopus\Applications\project\my.project\2016.02.574\logs' is denied. 13:46:05Error at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 13:46:05Error at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) 13:46:05Error at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) 13:46:05Error at System.IO.File.Open(String path, FileMode mode) 13:46:05Error at SharpCompress.Reader.IReaderExtensions.WriteEntryToFile(IReader reader, String destinationFileName, ExtractOptions options) 13:46:05Error at SharpCompress.Reader.IReaderExtensions.WriteEntryToDirectory(IReader reader, String destinationDirectory, ExtractOptions options) 13:46:05Error at Calamari.Integration.Packages.ZipPackageExtractor.Extract(String packageFile, String directory, Boolean suppressNestedScriptWarning) in Y:\work\14ffc968155e4956\source\Calamari\Integration\Packages\ZipPackageExtractor.cs:line 19 13:46:05Error at Calamari.Deployment.Conventions.ExtractPackageConvention.Install(RunningDeployment deployment) in Y:\work\14ffc968155e4956\source\Calamari\Deployment\Conventions\ExtractPackageConvention.cs:line 31 13:46:05Error at Calamari.Deployment.ConventionProcessor.RunInstallConventions() in Y:\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 60 13:46:05Error at Calamari.Deployment.ConventionProcessor.RunConventions() in Y:\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 28 13:46:05Error Running rollback conventions... 13:46:05Error System.ArgumentNullException: Value cannot be null. 13:46:05Error Parameter name: path 13:46:05Error at System.IO.DirectoryInfo..ctor(String path) 13:46:05Error at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.EnumerateFiles(String parentDirectoryPath, String[] searchPatterns) in Y:\work\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 181 13:46:05Error at Calamari.Integration.Scripting.PackagedScriptRunner.FindScripts(RunningDeployment deployment) in Y:\work\14ffc968155e4956\source\Calamari\Integration\Scripting\PackagedScriptRunner.cs:line 55 13:46:05Error at Calamari.Integration.Scripting.PackagedScriptRunner.RunScripts(RunningDeployment deployment) in Y:\work\14ffc968155e4956\source\Calamari\Integration\Scripting\PackagedScriptRunner.cs:line 29 13:46:05Error at Calamari.Deployment.ConventionProcessor.RunRollbackConventions() in Y:\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 69 13:46:05Error at Calamari.Deployment.ConventionProcessor.RunConventions() in Y:\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 48 13:46:05Error at Calamari.Commands.DeployPackageCommand.Execute(String[] commandLineArguments) in Y:\work\14ffc968155e4956\source\Calamari\Commands\DeployPackageCommand.cs:line 110 13:46:05Error at Calamari.Program.Execute(String[] args) in Y:\work\14ffc968155e4956\source\Calamari\Program.cs:line 38 13:46:06Fatal The remote script failed with exit code 100

Here’s the error that comes up in the Octopus Tentacle logs:

2016-02-05 13:58:09.6762 67 INFO listen://[::]:10933/ 67 Unhandled error when handling request from client: [::ffff:10.12.5.11]:57429 System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count) at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslStream.Read(Byte[] buffer, Int32 offset, Int32 count) at System.IO.StreamReader.ReadBuffer() at System.IO.StreamReader.ReadLine() at Halibut.Transport.Protocol.MessageExchangeStream.ReadLine() in y:\work\7ab39c94136bc5c6\source\Halibut\Transport\Protocol\MessageExchangeStream.cs:line 93 at Halibut.Transport.Protocol.MessageExchangeStream.ExpectNextOrEnd() in y:\work\7ab39c94136bc5c6\source\Halibut\Transport\Protocol\MessageExchangeStream.cs:line 67 at Halibut.Transport.Protocol.MessageExchangeProtocol.ProcessClientRequests(Func2 incomingRequestProcessor) in y:\work\7ab39c94136bc5c6\source\Halibut\Transport\Protocol\MessageExchangeProtocol.cs:line 110
at Halibut.Transport.SecureListener.ExecuteRequest(TcpClient client) in y:\work\7ab39c94136bc5c6\source\Halibut\Transport\SecureListener.cs:line 126`

I’m not sure why this is happening or which privs are required… Any help appreciated.

Cheers,

Hal

Hey,

So I made it work for now by removing the logs directory from the package.zip and turning off the appsettings.json writing option for the package deploy step.

Would still be keen to know what I’m doing wrong.

Hal

Hi,
Thanks for giving the 3.3-beta build a try, looks like you have already found some of its new features which will come in handy!

Thanks also for providing the task logs around this issue. I have tried to replicate your issue with a zip file containing a logs directory and with appsettings.json feature enabled. My Tentacle is running as a non-admin user on the machine.The deploy seemed to go just fine without any failures.

In your scenario, were any of the files in that folder written to disk? Would it be possible to run that Tentacle under elevated permissions to see if the problem is to do with the permissions of the account the service is running under.
Also, you mentioned that you disabled appsettings.json feature on the deployment to get it working. This should be an unrelated process based on the place that the exception looks to have been thrown on. Was this definitely required to be disabled to allow the deployment to succeed?
Thanks for letting us know about this problem, and for providing all the extra information. Hopefully we can come to a conclusion as to its cause to prevent this becoming an issue for anyone else.
Cheers,
Rob

Hi Rob,

Apologies for the late reply, we had a long weekend here. I think the initial permissions issue was was due to the logs but the appsettings.json thing also ran into the same permissions issue. Removing both of them allowed the entire zip contents to be written to the root directory and served the purpose in the mean time. How do I go about running the tentacle under different users?

Cheers,

Hal

Hi Hal,
To change the user account that the Tentacle is running under you just need to change the service’s “Log On” credentials via the services console.
The full set of steps can be seen in our documentation here.
Let me know if you run into any issues following this process, and if your permissions problems are resolved.
Cheers,
Robert

Hi,

Any updates on this one? I get the same error with the 3.3.0 release. I have tried change the account which the tentacle is running under but it did not help.

Mats

Deploying package: F:\Octopus\Files\My.Api.1.0.22.zip-09df276d-6f93-4ced-9524-feaebc75585f
15:52:50
Error
System.UnauthorizedAccessException: Access to the path ‘F:\Applications\Test\My.Api\1.0.22\logs’ is denied.
15:52:50
Error
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
15:52:50
Error
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
15:52:50
Error
at System.IO.FileStream…ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
15:52:50
Error
at System.IO.FileStream…ctor(String path, FileMode mode, FileAccess access, FileShare share)
15:52:50
Error
at System.IO.File.Open(String path, FileMode mode)
15:52:50
Error
at SharpCompress.Reader.IReaderExtensions.WriteEntryToFile(IReader reader, String destinationFileName, ExtractOptions options)
15:52:50
Error
at SharpCompress.Reader.IReaderExtensions.WriteEntryToDirectory(IReader reader, String destinationDirectory, ExtractOptions options)
15:52:50
Error
at Calamari.Integration.Packages.ZipPackageExtractor.Extract(String packageFile, String directory, Boolean suppressNestedScriptWarning) in Y:\work\14ffc968155e4956\source\Calamari\Integration\Packages\ZipPackageExtractor.cs:line 22
15:52:50
Error
at Calamari.Deployment.Conventions.ExtractPackageConvention.Install(RunningDeployment deployment) in Y:\work\14ffc968155e4956\source\Calamari\Deployment\Conventions\ExtractPackageConvention.cs:line 33
15:52:50
Error
at Calamari.Deployment.ConventionProcessor.RunInstallConventions() in Y:\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 60
15:52:50
Error
at Calamari.Deployment.ConventionProcessor.RunConventions() in Y:\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 28
15:52:50
Error
Running rollback conventions…
15:52:50
Error
System.ArgumentNullException: Value cannot be null.
15:52:50
Error
Parameter name: path
15:52:50
Error
at System.IO.DirectoryInfo…ctor(String path)
15:52:50
Error
at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.EnumerateFiles(String parentDirectoryPath, String[] searchPatterns) in Y:\work\14ffc968155e4956\source\Calamari\Integration\FileSystem\CalamariPhysicalFileSystem.cs:line 181
15:52:50
Error
at Calamari.Integration.Scripting.PackagedScriptRunner.FindScripts(RunningDeployment deployment) in Y:\work\14ffc968155e4956\source\Calamari\Integration\Scripting\PackagedScriptRunner.cs:line 55
15:52:50
Error
at Calamari.Integration.Scripting.PackagedScriptRunner.RunScripts(RunningDeployment deployment) in Y:\work\14ffc968155e4956\source\Calamari\Integration\Scripting\PackagedScriptRunner.cs:line 31
15:52:50
Error
at Calamari.Deployment.ConventionProcessor.RunRollbackConventions() in Y:\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 71
15:52:50
Error
at Calamari.Deployment.ConventionProcessor.RunConventions() in Y:\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 48
15:52:50
Error
at Calamari.Commands.DeployPackageCommand.Execute(String[] commandLineArguments) in Y:\work\14ffc968155e4956\source\Calamari\Commands\DeployPackageCommand.cs:line 113
15:52:50
Error
at Calamari.Program.Execute(String[] args) in Y:\work\14ffc968155e4956\source\Calamari\Program.cs:line 38
15:52:50
Fatal
The remote script failed with exit code 100

Hi Mats,
I Have just tried compressing a ASP.NET Core 1 project into a zip, uploaded it to Octopus Deploy, and then successfully unpackaged it to a Tentacle (on the same server), with the empty log folder contained. Could you please describe how you are compressing the contents? Also could I get you to upload your package to https://file.ac/SZ4YWwhKlZg/ so that we can try to un-package and reproduce this issue. This upload location is a secure repository that only we have access to retrieve from. It may be a problem with the extraction library we use getting tripped up with a specific compression format, so this is something that we would definitely like to get to the bottom of.
Let me know if you have any further questions or concerns about this package request.
Cheers,
Robert

Hi Rob!

Thanks for the quick reply. We are using a powershell in Teamcity to compress the folder that was created when running dnu publish. Then next step uploads the package to octopus. We are deploying to the same server as the Tentacle but have moved the application folder to F:\ as you will see in the logs and in the config. I’ve uploaded package, config, Tantacle logs and the scripts from TeamCity. Please let me know if you need more information.

Br

Mats

Hi Mats,
Thanks for sending this file through. Using this sample I have been able to reproduce and pinpoint where I think the issue is coming from. It appears to be in the SharpCompress compression library being used, which is having problems with reading the zip file header. So I can consider the correct change to make to this library, and reproduce the package myself locally, could you please confirm for me the process being used to create it (if its a PowerShell script just provide the line that performs the archiving) as well as just a few details about the OS on the machine that is doing the compression (given that its PowerShell I assume its some version of Windows).
Thanks again, and ill keep you updated with any progress to this issue. The current work around appears to be to ignore these empty folders (or put something in the empty folder prior to compression).
Cheers,
Rob

Hi Again,
Just an update with progress on this issue. I have managed to reproduce this exception using a zip file created from PowerShell so you don’t need to send any further information, thanks anyway.

It appears to be related of a non-standard behaviour in the System.IO.Compression assembly in the way it creates the file headers in the zip, appending a trailing \ character in the folder’s name. This appears to be something that is accounted for in several archival extraction libraries but I have had to raise a pull request for a fix to the library used within Octopus Deploy.

Hopefully if its merged within the next few days we can include the update in the next Octopus Deploy release. Ill keep you informed of when this occurs.
In the meantime the noted work around should still do the job.
Thanks again for providing the extra information for this case.
Cheers,
Rob

I have also run into this problem. Any update on this? Has the PR been accepted?

(It might be interesting to know that the built-in zip functionality in Windows 10 file explorer also has this problem. I am unable to modify or delete anything from a zip file created this way in Win 10.)

Hi,
This PR with this fix has been accepted however I am still awaiting for a build from the owner to get pushed to the Nuget repository. I have pinged him to see when it will be done but hopefully it wont be too much longer.
Thanks again for your patience.
Robert