I wrote this script recently as part of the release process from our development to QA environments. The assembly I was transferring to QA manages our data layer, and has an embedded resource that contains the NHibernate configuration. I did not want to recompile the assembly for QA, so I had to rewrite it dynamically.

Enter Mono.Cecil.

I wrote some wrapper classes around Mono.Cecil to help retrieve the embedded resource, and rewrite the XML for the NHibernate connection information. Merging that with the C# scripting process makes it all really convenient.

See the attached files for example code.

Note that the referenced ResourceManager.dll is built from the attached CecilExtensions.cs and NHibernateConfiguration.cs code files. You will have to reconstruct this yourself. Have fun.

The script file:
ResourceManager.dll source:

Last edited Aug 3, 2010 at 2:39 PM by treytomes, version 3


No comments yet.