gluck / il-repack

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

No logging when using ILRepack programmatically #305

Closed ChristopherHamkins closed 8 months ago

ChristopherHamkins commented 2 years ago

I am using ILRepack in a program to pack an assembly that is created using CodeDom with its references. This a my example:

`

       // Input assemblies are defined in an array
        string[] inputAssemblies = new string[2];
        inputAssemblies[0] = dllFilePath;
        inputAssemblies[1] = cphUtilsDllPath;

        // Pack with ILRepack
        string repackLogFile = Path.ChangeExtension(sourceCodeFilePath, ".log");
        RepackOptions repackOptions = new RepackOptions();
        repackOptions.DebugInfo = true;
        repackOptions.Internalize = true;
        repackOptions.LogFile = repackLogFile;
        repackOptions.Log = true;
        repackOptions.LogVerbose = true;
        repackOptions.OutputFile = Path.Combine(Path.GetDirectoryName(dllFilePath), "Packed" + Path.GetFileName(dllFilePath));
        repackOptions.InputAssemblies = inputAssemblies;
        repackOptions.TargetKind = ILRepack.Kind.Dll;
        repackOptions.SearchDirectories = new string[0];
        ILRepack packer = new ILRepack(repackOptions);

        try
        {
            packer.Repack();
        }
        catch (Exception e)
        {
            Console.WriteLine($"Failed to merge assemblies\r\n{e.Message}\r\n{e.StackTrace}");
        }

However, no output is written to the log file. The situation is the same even when I create the log file before creating the IlRepack instance or call Repack() on it.

The assembly is created just fine, there are no errors with that.

The LogFile from the RepackOptions never seems to be communicated to the RepackLogger.Open() method.

I am using version 2.0.18 downloaded from NuGet in a .Net Framework 4.6.1 application.