ILMerge & Keep Assembly Name

2019-07-19 11:13发布

问题:

I need to merge some dlls and both the file name and assembly name need to be the same as for my main dll (mydll.dll). I also need the pdb file. How do I get this done?

Here are a few things I tried:

  • Just use ILMerge mydll.dll .... /out:mydll.dll This fails with "Access to the path ...mydll.pdb is denied."

  • Rename mydll.dll to mydllTemp.dll and mydll.pdb to mydllTemp.pdb and then ILMerge mydelltemp.dll .... /out:mydll.dll This fails with "The pdb associated with ...mydlltemp.dll is out of date" I think this is because ilmerge looks at the assembly name to find the pdb, hence it looks for mydll.pdb which was renamed.

  • Rename mydll.dll to mydllTemp and then ILMerge mydelltemp.dll .... /out:mydll.dll This works without errors but when I attach the debugger to a process it does not trigger

  • ILMerge mydll.dll ... /out:mydlltemp.dll rename mydlltemp.dll to mydll.dll and mydlltemp.pdb to mydll.pdb Now I can attach the debugger to a process with breakpoints being triggered. However, the assembly name now is mydlltemp instead of mydll

So how can I get this to work AND have the original assembly name?

回答1:

You didn't really mention is this is in the course of standard development or if this is part of a build process.

If it's for standard development, do you really need everything merged just to test things out?

If it's for your build process, you can have the output go to a different directory (which you will probably need to mkdir first) and then you can reuse the same assembly name.



回答2:

merge to another directory, use /out:somedir\mydll.dll