Reputation: 9500
Given: - an assembly (e.g. "SomeLib.dll") - a text file (e.g. "myconfig.xml")
I need to embed the file myconfig.xml into the existing assembly SomeLib.dll
Please consider before pressing "Answer": I know about resources embeding during compile (csc.exe .. /embedresource:file ... ).
The thing is that I need to embed a resource after assembly has created.
Is it possible?
I also know about ILMerge. But havn't found how it could help.
Upvotes: 3
Views: 2396
Reputation: 21495
You might be able to use Resource Hacker to automate the modification of assembly from command line (their tutorial includes samples how to automate). After the modification you just have to resign the assembly.
Upvotes: 0
Reputation: 8159
You can use Cecil for this: load an assembly, add a resource, save to an assembly.
Upvotes: 1
Reputation: 13452
The Assembly Linker tool can be used to combine modules and resources into a signed assembly. However, I have not been able to find a way to use an existing assembly as input.
> al.exe SomeLib.module /out:SomeLib.dll /keyfile:SomeLib.snk /embed:myconfig.xml
Upvotes: 0
Reputation: 2124
Your going to need to resign the assembly after adding the resource. The whole point of assembly signing is to prevent people from modifying the contents of an assembly without being able to tell it was modified. You can use signcode.exe, http://msdn.microsoft.com/en-us/library/9sh96ycy(VS.80).aspx to resign the assembly after adding the resource, assuming you have the proper certificates.
Upvotes: 0