Closed MeFisto94 closed 4 months ago
We support the exclude file, read more at this issue: https://github.com/gluck/il-repack/issues/323
/internalize:"repackExclude.txt"
Keeping the issue open to document the exclude file in the command line help
It's still not fully possible to exclude via file name but this something I urgently need for a project that utilizes Grpc.Core because it includes some native dlls that cannot be repacked.
Currently, there is no way to exclude them (except for deleting prior to ILRepack).
I tried this with different regex / wildcard variations:
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="ILRepacker" AfterTargets="Build">
<ItemGroup>
<InputAssemblies Include="$(OutputPath)*.dll"/>
</ItemGroup>
<ItemGroup>
<!-- native dlls cannot be repacked -->
<ExcludeFiles Include="grpc_csharp_ext.x86.dll" />
<ExcludeFiles Include="$(OutputPath)grpc_csharp_ext.x64.dll" />
</ItemGroup>
<ILRepack
Parallel="true"
Internalize="true"
InputAssemblies="@(InputAssemblies)"
InternalizeExclude="@(ExcludeFiles)"
TargetKind="Dll"
OutputFile="$(OutputPath)\$(AssemblyName).dll"
Wildcards="true"
/>
</Target>
</Project>
... but none of the files will be excluded
1>NET48.CLI.NugetProxy -> D:\source\mycompany.imageserver\Test Projects\NET48.CLI.NugetProxy\bin\Release\net4.8\NET48.CLI.NugetProxy.dll
1>Added assembly 'bin\Release\net4.8\Azure.Core.dll'
1>Added assembly 'bin\Release\net4.8\Azure.Identity.dll'
1>Added assembly 'bin\Release\net4.8\MyCompany.Database.NET48.dll'
1>Added assembly 'bin\Release\net4.8\MyCompany.DependencyInjection.NET48.dll'
1>Added assembly 'bin\Release\net4.8\MyCompany.Grpc.NET48.dll'
1>Added assembly 'bin\Release\net4.8\MyCompany.ImageServer.Interface.NET48.dll'
1>Added assembly 'bin\Release\net4.8\MyCompany.Logging.NET48.dll'
1>Added assembly 'bin\Release\net4.8\MyCompany.Shared.NET48.dll'
1>Added assembly 'bin\Release\net4.8\Grpc.Core.Api.dll'
1>Added assembly 'bin\Release\net4.8\Grpc.Core.dll'
1>Added assembly 'bin\Release\net4.8\Grpc.Net.Client.dll'
1>Added assembly 'bin\Release\net4.8\Grpc.Net.Common.dll'
1>Added assembly 'bin\Release\net4.8\grpc_csharp_ext.x64.dll'
1>Added assembly 'bin\Release\net4.8\grpc_csharp_ext.x86.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Bcl.AsyncInterfaces.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Data.SqlClient.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Data.SqlClient.SNI.arm64.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Data.SqlClient.SNI.x64.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Data.SqlClient.SNI.x86.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.Configuration.Abstractions.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.Configuration.Binder.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.Configuration.CommandLine.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.Configuration.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.Configuration.EnvironmentVariables.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.Configuration.FileExtensions.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.Configuration.Json.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.Configuration.UserSecrets.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.DependencyInjection.Abstractions.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.DependencyInjection.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.Diagnostics.Abstractions.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.Diagnostics.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.FileProviders.Abstractions.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.FileProviders.Physical.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.FileSystemGlobbing.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.Hosting.Abstractions.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.Hosting.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.Logging.Abstractions.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.Logging.Configuration.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.Logging.Console.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.Logging.Debug.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.Logging.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.Logging.EventLog.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.Logging.EventSource.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.Options.ConfigurationExtensions.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.Options.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Extensions.Primitives.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Identity.Client.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.Identity.Client.Extensions.Msal.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.IdentityModel.Abstractions.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.IdentityModel.JsonWebTokens.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.IdentityModel.Logging.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.IdentityModel.Protocols.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.IdentityModel.Protocols.OpenIdConnect.dll'
1>Added assembly 'bin\Release\net4.8\Microsoft.IdentityModel.Tokens.dll'
1>Added assembly 'bin\Release\net4.8\NET48.CLI.NugetProxy.dll'
1>Added assembly 'bin\Release\net4.8\protobuf-net.Core.dll'
1>Added assembly 'bin\Release\net4.8\protobuf-net.dll'
1>Added assembly 'bin\Release\net4.8\protobuf-net.Grpc.dll'
1>Added assembly 'bin\Release\net4.8\protobuf-net.Grpc.Native.dll'
1>Added assembly 'bin\Release\net4.8\System.Buffers.dll'
1>Added assembly 'bin\Release\net4.8\System.ClientModel.dll'
1>Added assembly 'bin\Release\net4.8\System.Collections.Immutable.dll'
1>Added assembly 'bin\Release\net4.8\System.Configuration.ConfigurationManager.dll'
1>Added assembly 'bin\Release\net4.8\System.Diagnostics.DiagnosticSource.dll'
1>Added assembly 'bin\Release\net4.8\System.IdentityModel.Tokens.Jwt.dll'
1>Added assembly 'bin\Release\net4.8\System.IO.FileSystem.AccessControl.dll'
1>Added assembly 'bin\Release\net4.8\System.Memory.Data.dll'
1>Added assembly 'bin\Release\net4.8\System.Memory.dll'
1>Added assembly 'bin\Release\net4.8\System.Net.Http.WinHttpHandler.dll'
1>Added assembly 'bin\Release\net4.8\System.Numerics.Vectors.dll'
1>Added assembly 'bin\Release\net4.8\System.Runtime.CompilerServices.Unsafe.dll'
1>Added assembly 'bin\Release\net4.8\System.Security.AccessControl.dll'
1>Added assembly 'bin\Release\net4.8\System.Security.Cryptography.ProtectedData.dll'
1>Added assembly 'bin\Release\net4.8\System.Security.Permissions.dll'
1>Added assembly 'bin\Release\net4.8\System.Security.Principal.Windows.dll'
1>Added assembly 'bin\Release\net4.8\System.ServiceModel.Http.dll'
1>Added assembly 'bin\Release\net4.8\System.ServiceModel.Primitives.dll'
1>Added assembly 'bin\Release\net4.8\System.Text.Encodings.Web.dll'
1>Added assembly 'bin\Release\net4.8\System.Text.Json.dll'
1>Added assembly 'bin\Release\net4.8\System.Threading.Channels.dll'
1>Added assembly 'bin\Release\net4.8\System.Threading.Tasks.Extensions.dll'
1>Added assembly 'bin\Release\net4.8\System.ValueTuple.dll'
1>Excluding namespaces/types matching pattern 'grpc_csharp_ext.x86.dll' from being internalized
1>Excluding namespaces/types matching pattern 'bin\Release\net4.8\grpc_csharp_ext.x64.dll' from being internalized
1>D:\source\mycompany.imageserver\Test Projects\NET48.CLI.NugetProxy\ILRepack.targets(16,9): error : parsing "OutputPath)grpc_csharp_ext.x64.dll" - Too many )'s.
1>Done building project "NET48.CLI.NugetProxy.csproj" -- FAILED.
Can you try this:
<ItemGroup>
<InputAssemblies Include="$(OutputPath)*.dll" />
<InputAssemblies Remove="$(OutputPath)grpc_csharp_ext.x86.dll" />
<InputAssemblies Remove="$(OutputPath)grpc_csharp_ext.x64.dll" />
</ItemGroup>
Then build your project from the command line using msbuild /bl
and open the resulting msbuild.binlog using the viewer from https://msbuildlog.com.
In the viewer, verify that the two files you want excluded are actually excluded from the InputAssemblies item.
Thanks! It even works with wildcards, i.e.
<InputAssemblies Remove="$(OutputPath)*.x86.dll" />
<InputAssemblies Remove="$(OutputPath)*.x64.dll" />
<InputAssemblies Remove="$(OutputPath)*.arm64.dll" />
... did the trick (there were other native dlls that need exclusion).
Currently, IL Repack is coded with the feature parity towards ILMerge command line arguments in mind, but not using IL Repack as dependency.
As such, a good feature would be to be able to pass a predicate/
Func<Type, bool>
/delegate to the repacking process to determine which types should be included/merged in the process.Currently, this can only be done with an attribute, which is why I need manual CECIL'ing to flag types that should be dropped in the process. It would be much better to allow the caller to just determine that via their criteria and only using predicates (i.e. NO RegEx or other solutions)