Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for remapping references #234

Open
richard-fine opened this issue Aug 14, 2018 · 4 comments
Open

Support for remapping references #234

richard-fine opened this issue Aug 14, 2018 · 4 comments

Comments

@richard-fine
Copy link

I've got a bunch of assemblies {A1.dll, A2.dll, A3.dll...} and corresponding test assemblies {A1.Tests.dll, A2.Tests.dll, A3.Tests.dll...} I'm merging the main assemblies together into a single A.dll for distribution, and now I'd like to merge all the tests together as well into A.Tests.dll to distribute alongside it.

However, because the all of the Tests.dll assemblies were originally built prior to stuff being merged, the resulting A.Tests.dll assembly still references all the pre-merged {A1.dll, A2.dll, A3.dll, ...} assemblies. This is no good...

I could recompile the A1.Tests.dll... dlls from scratch with different references, but it's not great to redo all that compilation work just to change a reference. I could also write a custom tool using Cecil to edit the references, but that again seems inefficient considering that ILRepack is already doing most of that work.

So I'm wondering about having some kind of /remapRef:from:to or /remapRefsFile:file command-line parameter, which my build code could use to specify for each of the A1.dll, "remap this to the merged A.dll".

What do you think?

@richard-fine
Copy link
Author

Or perhaps more simply than generic reference rewriting: /alreadyMerged: which takes the output of a previous ILMerge run, loads all the types from it, and rewrites any references in the inputs that match the full names of those types to point at the new assembly.

@gjonespf
Copy link

gjonespf commented Oct 8, 2019

Did you ever find a workaround or tool to make this happen? This would be incredibly useful. I've not managed to find any simple solution short of manually hacking things up or building a tool to do same.

@gluck
Copy link
Owner

gluck commented Oct 9, 2019

Note that ILRepack creates/updates a resource in the merged assembly ILRepack.list that contains the list of pre-merge assemblies.
Looks like maybe it could leverage that during the merge process of the tests assemblies, and resolve any missing reference towards a merged assembly of said reference.
If it resolves this way only as a fallback, could even be the default behavior of ILRepack (better than failing the merge), feel free to work out a PR.

It still requires that the original (non-test) assembly was created with ILRepack, as ILMerge doesn't maintain that metadata.

@deniszykov
Copy link
Contributor

deniszykov commented Jan 8, 2024

It is possible to avert problem by generating type forwarding assemblies in place of merged ones https://learn.microsoft.com/en-us/dotnet/standard/assembly/type-forwarding

But is big chunk of work to implement this feature, I'm not sure some one will make PR for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants