I have just been proven wrong, and this happens so infrequently that it warrants its own blog post (kidding!)
In a number of the installments of the Summer of NHibernate screencast series, I have repeatedly made the assertion that when one makes a change to an embedded resource in their Visual Studio project, the developer has to explicitly select REBUILD for that project because a change to an embedded resource in a project isn’t considered by Visual Studio to be a change that will ‘trip’ the BUILD action into considering that the project needs to be recompiled.
In the context of NHibernate, this issue relates to managing changes to the .hbm.xml mapping files that my screencasts have recommended be managed as embedded resources in one’s Data Transfer Object project. When working in the screencasts on tweaking the contents of these mapping files, I have repeatedly advised that the developer needs to take caution to remember to explicitly call REBUILD on the project that contains the mapping files because otherwise Visual Studio will not recompile the assembly for that project and the mapping file embedded resources will not be updated in the assembly.
THIS IS WRONG (sort of!)
An astute viewer sent me a comment that suggested that in at least one of the screencasts I failed to REBUILD this project and yet the updated mapping file changes were still properly updated in the assembly — suggesting that an explicit REBUILD was not required. I was skeptical of this, but promised to investigate. I have done so now and my investigation has turned up the following: Visual Studio 2008 does indeed now ‘properly’ consider a change to an embedded resource item as a condition for which it will BUILD the project.
This is wonderfully helpful and yet entirely stealthy — I can find no documentation, announcement, or change-log for VS 2008 that suggests this is a change from past behavior and yet it clearly is such. Visual Studio 2005 definitely still evidences the behavior that I was indicating where you must explicitly invoke REBUILD on the project to get changes to embedded resources to be reflected in your compiled assembly.
I can see how this wouldn’t really make headlines for MS in selling updates to VS 2008 (e.g., "Rush out and get your Update to Visual Studio 2008 and reap the rewards of auto-building when embedded resources have changed!" is hardly as effective a selling point as "now with embedded designers for WPF!") but I would have liked to have heard at least something about this somewhere!
In any case, I clearly missed this and kept my old VS 2005-style of working without ever considering that it might have been ‘fixed’ in VS 2008. Now I wonder how many other ‘habitual work-arounds’ I have in my arsenal are no longer needed either….