0

I am making a compressed copy of our wwwroot file via powershell and the Compress-Archive command. Is there a compelling reason to stop iis (or the website/apppool) before making a copy. I will be using this copy to update our test environment.

The documentation around the Compress-Archive doesn't make it clear what will happen if a file is locked. https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.archive/compress-archive?view=powershell-7.2

  • People do not zip up things from IIS to deploy to their test environment, but use `dotnet publish` from the source code to generate artifacts, https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-7.0&tabs=visual-studio. So, instead of asking a question that makes little sense, you should move to the common approach. – Lex Li Nov 09 '22 at 05:36
  • @LexLi - I am using an application where I don't work directly with the source code. We don't use donet publish to publish our production app. In my scenario I only need to grab the wwwroot file. – Tony Visconti Nov 09 '22 at 15:22
  • Then sadly nobody can give you a definite answer on what might happen with that approach. You might be able to grab most of the things needed, but only the original developer(s) can confirm if anything is missing there. – Lex Li Nov 09 '22 at 17:56

1 Answers1

0

If you are not completely sure, you'd better stop this website and recycle the application pool, any uncertainty may cause your compression to be incomplete, because there may be some files in your project folder that are still in process , which will cause these files to fail to compress.

YurongDai
  • 1,362
  • 1
  • 2
  • 7
  • do you have any insights into whether or not Compress-Archive will provide feedback/fail when it is unable to compress a specific file? – Tony Visconti Nov 11 '22 at 15:49
  • If some files in the website folder are already opened, so Compress-Archive cannot add them to the zip, it may report this failure to stderr, throwing a non-terminating error. For powershell error handling you can refer to this: https://github.com/MicrosoftDocs/PowerShell-Docs/issues/1583 – YurongDai Nov 17 '22 at 05:27