0

Cross-posted from https://devops.stackexchange.com/questions/13583/azure-release-pipeline-fails-using-expand-archive-command as there has been zero activity there :(.

Sometime in the last week, our pipeline started using Expand-Archive to open the .zip file during the "IIS Web App Deployment" step instead of 7-Zip. It does not appear that this was done by our team, so I'm presuming this may have been changed in DevOps.

We are deploying to Server 2012R2.

Several of our apps are okay with this, however one of them fails to expand. It seems as if this might be related to path length (this app uses some very deep folder nesting with Angular) since I can manually run the command successfully if I shorten the destination path.

The command that fails to runs on the server is:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -NonInteractive -Command "Expand-Archive -Path "C:\azagent\A3\_work\r1\a\thisistheazurejobname\drop\thisisourappsnamex.zip" -DestinationPath "C:\azagent\A3\_work\_temp\temp_web_package_8157628602055582" -Force"

If I reduce it to:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -NonInteractive -Command "Expand-Archive -Path "C:\azagent\A3\_work\r1\a\thisistheazurejobname\drop\thisisourappsnamex.zip" -DestinationPath "C:\azagent\A3\_work\_temp\short" -Force"

...it appears to work fine.

Obviously, I am speculating that it's a path-length issue, but evidence does seem to support it. Also, I reconstructed what would have been the 7-Zip command and it worked as expected:

C:\azagent\A3\_work\_tasks\IISWebAppDeploymentOnMachineGroup_1b467810-6725-4b6d-accd-886174c09bba\0.184.0\node_modules\webdeployment-common-v2\7zip\7z.exe x -oC:\azagent\A3\_work\_temp\temp_web_package_8157628602055582 C:\azagent\A3\_work\r1\a\thisistheazurejobname\drop\thisisourappsnamex.zip

I looked at the advice here and found we are already using the setting: https://igorpuhalo.wordpress.com/2019/08/29/overcoming-long-path-problem-in-powershell/

My hope is that someone knows what may have changed, can suggest a straightforward way to go back to using 7-Zip, or a way to make Expand-Archive to work.

1 Answers1

0

The Expand-Archive command in IIS Web App Deployment task is run by this task by default. We couldn't change the command to use 7-Zip in this tasks.

Here is the Task source code. It will use Powershell.

can suggest a straightforward way to go back to using 7-Zip, or a way to make Expand-Archive to work.

You could try the following two methods to change to use 7-zip or make the command work:

1.To use 7-zip, you need to convert the steps of IIS web deploy into a Command Line Task.

Here are the steps:

In the Release Log , you could see the Expand-Archive command and the msdeploy command.

enter image description here

You could copy these two command to Command Line task and change the -source parameterms to the zip package path in deploy command.

for example:

"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe"   -verb:sync -source:package='C:\azagent\A4\_work\r32\a\_TEST PROJECT-ASP.NET Core (.NET Framework)-CI (82)\drop\WebApp.zip' -dest:auto -setParam:name='IIS Web Application Name',value='kevin0322' -enableRule:AppOffline -enableRule:DoNotDeleteRule

Then you could use the 7-Zip command to replace the first Powershell command.

2.You could use Powershell 7 instead of Powershell\v1.0.

Here is the doc about installing powershell 7

Powershell 7 has more powerful features. Refer to this ticket.

After installing Powershell 7 and set the system environment, the task will use Powershell 7 .

enter image description here

To set system env, you could navigate to system -> Environment variables.

enter image description here

Kevin Lu-MSFT
  • 20,786
  • 3
  • 19
  • 28
  • 1
    Kevin... you give me hope! I'll give it a whirl in the morning, but what you describe makes sense off-hand. I'll should be able to post an update tomorrow! I am curious, though... it was using 7-Zip a week or two ago. What changed it? – Rich Claussen Mar 22 '21 at 04:06
  • Hi @RichClaussen. You could check the version of the IIS web deploy task. I think it may be that the developer changed the behavior of the task as the task is updated. I haven’t used this task recently, but I checked the logs of tasks that ran earlier. The log only contain the msdeploy step(without Expand-Archive step). – Kevin Lu-MSFT Mar 22 '21 at 05:21
  • since the steps the task runs are preset. We cannot change it. But I think the above methods can help you solve this issue. Feel free to let me know the result. – Kevin Lu-MSFT Mar 22 '21 at 05:24
  • Great question that I should have included in the above... the 'before' version: Version : 0.179.0. The 'after' version: Version : 0.184.0. – Rich Claussen Mar 22 '21 at 14:47
  • 1
    It looks like we may have succeeded! I had a little trouble in that I didn't realize that I needed to re-register the agent to get it working. Once I did that, it started using the new PS7 command! – Rich Claussen Mar 22 '21 at 20:02
  • ...AND AFTER ALL THAT! Looks like the pipeline step was revisioned again and has gone back to using 7-Zip! :D – Rich Claussen Mar 23 '21 at 19:41