Skip to content

Commit 4c81668

Browse files
jonpryordellis1972
authored andcommitted
[Xamarin.Android.Build.Tasks] Extract resources with S.I.C.ZipFile. (#41)
Ionic.Zip.dll, as provided by the Unofficial.Ionic.Zip 1.9.1.8 NuGet package, is broken. [It hardcodes `\` as directory separator char][0], which breaks all manner of things, and when we try to extract and unzip embedded resources from assemblies, it fails: Error executing task ResolveLibraryProjectImports: System.ArgumentException: Path is empty at System.IO.Directory.CreateDirectory (System.String path) <0x1a20ca0 + 0x0011c> in <filename unknown>:0 at Ionic.Zip.ZipEntry.InternalExtract (System.String baseDir, System.IO.Stream outstream, System.String password) <0x3af4b78 + 0x002e7> in <filename unknown>:0 I'm not sure *why* "path is empty" -- the callstack isn't very helpful -- but it *is* empty, which means if a project references an assembly which contains e.g. @(AndroidResource), everthing breaks. Fix the `ResolveLibraryProjectImports` task so that instead of using Ionic.Zip.dll to extract embedded resources we instead use System.IO.Compression.ZipFile (in System.IO.Compression.FileSystem.dll, new in .NET 4.5). Note: *Other* uses of Ionic.Zip.dll are similarly suspect but *are not fixed*. Fixing (removing?) Ionic.Zip.dll will be done later. [0]: https://gitter.im/xamarin/xamarin-android?at=572d97caf36daf63798d6033
1 parent ba00293 commit 4c81668

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
using System.Collections.Generic;
33
using System.Diagnostics;
44
using System.IO;
5+
using System.IO.Compression;
56
using System.Linq;
67
using System.Xml;
78
using System.Xml.Linq;
89
using Mono.Cecil;
910
using Microsoft.Build.Utilities;
1011
using Microsoft.Build.Framework;
1112
using System.Text.RegularExpressions;
12-
using Ionic.Zip;
1313

1414
using Java.Interop.Tools.Cecil;
1515

@@ -232,9 +232,7 @@ void Extract (
232232

233233
// temporarily extracted directory will look like:
234234
// __library_projects__/[dllname]/[library_project_imports | jlibs]/bin
235-
using (var zip = new ZipFile (finfo.FullName)) {
236-
Files.ExtractAll (zip, outDirForDll);
237-
}
235+
ZipFile.ExtractToDirectory (finfo.FullName, outDirForDll);
238236

239237
// We used to *copy* the resources to overwrite other resources,
240238
// which resulted in missing resource issue.

src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
<Reference Include="Microsoft.Build.Utilities.v4.0" />
4141
<Reference Include="System" />
4242
<Reference Include="System.Core" />
43+
<Reference Include="System.IO.Compression" />
44+
<Reference Include="System.IO.Compression.FileSystem" />
4345
<Reference Include="System.Xml.Linq" />
4446
<Reference Include="System.Xml" />
4547
<Reference Include="Mono.Cecil">

0 commit comments

Comments
 (0)