Skip to content

Commit

Permalink
- Issue #319: "Bad IL format" on self-contained linux-x64 builds if u…
Browse files Browse the repository at this point in the history
…sing namespace with same name as assembly
  • Loading branch information
oleg-shilo committed Dec 15, 2022
1 parent 6a0bb4d commit 875c87d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/CSScriptLib/src/CSScriptLib/AssemblyResolver.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using CSScripting;
using CSScriptLib;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -45,7 +46,10 @@ static public bool IsLegalPathToken(string name)
return name.IndexOfAny(illegalChars) != -1;
}

static internal ResolveAssemblyHandler FindAssemblyAlgorithm = DefaultFindAssemblyAlgorithm;
/// <summary>
///
/// </summary>
static public ResolveAssemblyHandler FindAssemblyAlgorithm = DefaultFindAssemblyAlgorithm;

/// <summary>
/// Resolves namespace/assembly(file) name into array of assembly locations (local and GAC ones).
Expand Down Expand Up @@ -115,8 +119,15 @@ public static string[] FindLocalAssembly(string name, string dir)
//cannot just check Directory.Exists(dir) as "name" can contain sum subDir parts
if (Directory.Exists(Path.GetDirectoryName(asmFile)))
{
//test well-known assembly extensions first
foreach (string ext in new string[] { "", ".dll", ".exe" })
//test first the exact file name and then well-known assembly extensions first
var possibleExtensions = new string[] { "", ".dll", ".exe" };

// if user specified file name has no extension test first any file that has well-known assembly extension
// triggered by https://github.com/oleg-shilo/cs-script/issues/319
if (name.GetExtension() == "")
possibleExtensions = new string[] { ".dll", ".exe", "" };

foreach (string ext in possibleExtensions)
{
string file = asmFile + ext; //just in case if user did not specify the extension
if (ignoreFileName != Path.GetFileName(file) && File.Exists(file))
Expand Down

0 comments on commit 875c87d

Please sign in to comment.