Skip to content

ILRepack throws unhandled exception when /lib folder ends with a slash #415

@LazaroOnline

Description

@LazaroOnline

(ILRepack Version 2.0.44, running on Windows 11 up to date)

When using the /lib: option, if the folder specified ends with the slash character \ then ILRepack throws the error:

Example to reproduce the error:

ILRepack.exe /lib:"C:\TestFolder\"  /out:"C:\app.dll"  "bin\app.dll"  "bin\dep1.dll"

Error:

System.ArgumentException: Illegal characters in path.
   at System.IO.LongPathHelper.Normalize(String path, UInt32 maxPathLength, Boolean checkInvalidCharacters, Boolean expandShortPaths)
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.GetFullPathInternal(String path)
   at ILRepacking.RepackOptions.<>c.<Parse>b__191_0(String d) in /_/ILRepack/RepackOptions.cs:line 274
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.<DistinctIterator>d__64`1.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at ILRepacking.RepackOptions.Parse() in /_/ILRepack/RepackOptions.cs:line 271
   at ILRepacking.RepackOptions..ctor(ICommandLine commandLine, IFile file) in /_/ILRepack/RepackOptions.cs:line 168
   at ILRepacking.Application.Main(String[] args) in /_/ILRepack/Application.cs:line 26

If you remove the slash like this it would work:

ILRepack.exe /lib:"C:\TestFolder"  /out:"C:\app.dll"  "bin\app.dll"  "bin\dep1.dll"

But in some automated pipelines, or MSBuild, the path already comes with the ending slash, making things harder.

Ideally ILRepack would catch that exception and just work with or without any number of ending slashes of any type \ or / just like any path in windows, so these should all work:

ILRepack.exe /lib:"C:\TestFolder"  ..."
ILRepack.exe /lib:"C:\TestFolder\"  ..."
ILRepack.exe /lib:"C:\TestFolder\\"  ..."
ILRepack.exe /lib:"C:\TestFolder/"  ..."
ILRepack.exe /lib:"C:\TestFolder//"  ..."
ILRepack.exe /lib:"C:\TestFolder//\\/\/\"  ..."

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions