Skip to content

Add zip files in working directory to assembly search path #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/csharp/Microsoft.Spark/Utils/AssemblyLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Reflection;
using System.Runtime.InteropServices;

Expand Down Expand Up @@ -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)
{
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, rather than extracting all .zip files within the folder. I would prefer to extract only the applications .zip file if present. I don't, however, know the project well enough to know if it is possible to access the application .zip parameter that's passed to DotNetRunner from C#.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #194 as an alternative way of potentially implementing this.

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();
}
}
Expand Down