gluck / il-repack

Open-source alternative to ILMerge
Apache License 2.0
1.16k stars 214 forks source link

ExcludeFiles appears to be being ignored? #323

Closed S-Tasker closed 8 months ago

S-Tasker commented 1 year ago

Hey!

When using the following command line arguments again ilrepack, i would expect the regex entries in my file to be excluded from the merged dll: /t:library /internalize:"$(MSBuildProjectDirectory)\repackExclude.txt"; /wildcards "$(PublishDir)\*.dll" /out:"$(PublishDir)\..\$(TargetFileName)" /verbose" />

The file is being read (i checked this by specifying a file that didn't exist, and watching ilrepack throw an error). However the content is ignored.

I'd like to ignore Microsoft.Extensions.Configuration.Extensions and Microsoft.Extensions.Configuration.Extensions.Abstractions

So my "repackExclude.txt" file looks like: ^Microsoft.Extensions.Configuration(.){0,}$

I've also tried:

Microsoft\.Extensions\.Configuration\.IConfiguration
^(.){0,}Microsoft.Extensions.Configuration(.){0,}$
Microsoft.Extensions.Configuration.Extensions.dll
Microsoft.Extensions.Configuration.Extensions.Abstractions.dll

etc.

I understand it's supposed to be 1 regex per line, but nothing seems to actually exclude the DLLs from the merge, and i see:

INFO: Adding assembly for merge: C:\src\project\bin\Debug\netstandard20\publish\Microsoft.Exten sions.Configuration.Abstractions.dll

Am i doing something wrong, or does it not work?

S-Tasker commented 1 year ago

In the end, i added a task to delete the DLLs from the output directory before running a Repack. However now I wonder how the exclude is supposed to work in general.

KirillOsenkov commented 8 months ago

Don't specify the .dll file extension, it works off the assembly name only: https://github.com/gluck/il-repack/blob/e6e30d86e80e9e299de61ddd794762340b1ab798/ILRepack/Steps/TypesRepackStep.cs#L149

Also regexes are supported for type full names only, not for assembly names: https://github.com/gluck/il-repack/blob/e6e30d86e80e9e299de61ddd794762340b1ab798/ILRepack/RepackOptions.cs#L47-L52

This is where exclude type full name regexes are used: https://github.com/gluck/il-repack/blob/e6e30d86e80e9e299de61ddd794762340b1ab798/ILRepack/Steps/TypesRepackStep.cs#L136-L139

I made it so that specifying the .dll extension in the file works now: https://github.com/gluck/il-repack/commit/4feb42ee6ea9906dc815846010918ced578c907a