From 1173e6d1530c66c0dd9297209120669173efa2f3 Mon Sep 17 00:00:00 2001 From: AeroXuk Date: Thu, 1 Aug 2019 00:20:16 +0100 Subject: [PATCH] Extract zip files within the working directory and add them to the assembly search path. --- src/csharp/Microsoft.Spark/Utils/AssemblyLoader.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/csharp/Microsoft.Spark/Utils/AssemblyLoader.cs b/src/csharp/Microsoft.Spark/Utils/AssemblyLoader.cs index 343f57fc9..a775ba0e7 100644 --- a/src/csharp/Microsoft.Spark/Utils/AssemblyLoader.cs +++ b/src/csharp/Microsoft.Spark/Utils/AssemblyLoader.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.IO.Compression; using System.Reflection; using System.Runtime.InteropServices; @@ -56,6 +57,19 @@ internal static string[] GetAssemblySearchPaths() searchPaths.Add(Directory.GetCurrentDirectory()); searchPaths.Add(AppDomain.CurrentDomain.BaseDirectory); + FileInfo[] archives = new DirectoryInfo(Directory.GetCurrentDirectory()) + .GetFiles("*.zip"); + foreach (var archive in archives) + { + string extractedPath = Path.Combine(archive.DirectoryName, + Path.GetFileNameWithoutExtension(archive.FullName)); + if (!File.Exists(extractedPath)) + { + ZipFile.ExtractToDirectory(archive.FullName, extractedPath); + searchPaths.Add(extractedPath); + } + } + return searchPaths.ToArray(); } }