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.