0

I try to Unzip zip file with folders. Unarchiving of files from "root" directory goes without problems, but as soon the process gets to folders, I get error MSB3936.

Is there any workaround for that problem, using MSBuild task?

Inline MSBuild task (using .Net System.IO.Compression.ZipFile.ExtractToDirectory) works fine with zip with subfolders. So it's even more strange that embedded MSBuild task doesn't work (including VS 2019 (16) as well).

Andrey Minakov
  • 545
  • 2
  • 5
  • 19

1 Answers1

2

Is there any workaround for that problem, using MSBuild task?

For now, a MSBuild task may not help solve it. This is one issue#3884 (or bug maybe) about unzip task. And you can find the post from this link. Several members with similar issue have voted for it, including me. Hope the coming MSBuild 16.1 will fix this. Though according the Milestone this may need some time.

As a workaround: You can add a 'ContinueOnEerror' to the unzip task.

  Target Name="UnzipArchive" BeforeTargets="Build">
    <Unzip ContinueOnError="true"
        SourceFiles="C:\Users\lancel\Desktop\AFolder.zip"
        DestinationFolder="$(OutputPath)\unzipped"
        OverwriteReadOnlyFiles="true"
        />
  </Target>

For 'ContinueOnError', if you set this on a MSBuild Task, then the build process will continue even though the task executes with failure.

Good news is that after my test,though the error message will be like:

Failed to open unzip file "AFolder/c/" to "xxx\bin\Debug\unzipped\AFolder\c\".  Could not find a part of the path 'C:\xxx\bin\Debug\unzipped\AFolder\c\

Actually, the task runs successfully, which means the unzip task executes well.

But for some unknown reason it will throw errors which disturb the whole build process.

So add 'ContinueOnError=true', after that, the build will succeed and the error message will be turned into warning message. Also,the folder will be unzipped well to DestinationFolder.

In addition: Delete all existing unzipped folder in your DestinationFolder.Build the project again, check the content of zipped folder and unzipped folder, on my side they are the same.

LoLance
  • 25,666
  • 1
  • 39
  • 73
  • Please could you say is it possible to turn of the warning message as well? – Andrey Minakov Mar 21 '19 at 14:28
  • 1
    @AndreyMinakov I'm afraid not. You can have a look at [this similar issue](https://stackoverflow.com/questions/54383985/how-to-suppress-found-conflicts-between-different-versions-of-warning/54397588#54397588). Also, [this link](https://stackoverflow.com/questions/1023858/how-to-suppress-specific-msbuild-warning) has more details. For now, we can only suppress CS warnings but not MSB warnings. Of course, seems there has way to supress3270, and you can check if it works for MSB3936. – LoLance Mar 21 '19 at 16:45
  • This is a hack if you really need it, but you can create a Directory.Build.rsp adjacent to the csproj you want to suppress this warning in and add the contents "/WarnAsMessage:MSB3936". – mjsabby Dec 30 '19 at 10:15