Hiding Your hbm.xml files in Visual Studio (or not)

I had this cool idea. What if I could hide my NHibernate Entity.hbm.xml files behind their respective c# files in the Solution Explorer. This would tidy things up a bit as I’m getting a bit overloaded in my project at work.

It turns out that this is pretty easy to accomplish… visually. Here’s what we’re trying to accomplish:


Busting out the .csproj file I can edit the file to go from:

<EmbeddedResource Include="Class1.hbm.xml" />


<EmbeddedResource Include="Class1.hbm.xml">

I even found a macro that does it for you rather than having to hack the visual studio project file directly.

Unfortunately it suddenly broke all my unit tests. Turns out that when adding “dependent upon” it does more than just the visual but actually changes the name (and type?) of the file. Here’s what it looks like in Reflector before:
Plain Old XML

Here’s what it looks like after:
Compiled XML

I spent an hour or so on the MSDN trying to figure out how to solve this problem, but I can’t seem to figure out how to do it. It looks like someone else had this EXACT idea and problem.

Anyone have any ideas on how to solve this?

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>