Nice hidden .shfbproj template feature

Topics: Developer Forum, User Forum
Sep 29, 2010 at 3:57 PM

After seeing that .shfbproj's were just msbuild projects, I went ahead and added a line at the top of my project's .shfbproj file so that it looks like this:

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">    
    <Import Project="$(SHFBROOT)\..\myCompany\SandcastleDefaults.shfbproj" />

I then created the appropriate "SandcastleDefaults.shfbproj" based off a project I set up exactly how I wanted with a basic understanding of how msbuild works. In addition, I changed the ProjectGuid of the template to be safe. Next, I removed everything from my project's .shfbproj that was covered by the new template. 

When I re-opened my project's .shfbproj file, SHFB showed the values from the template except in the cases where I had specifically overwritten it. Even better, SHFB doesn't write out the property unless I change it (e.g. copy-on-write) which is exactly what I wanted.

There isn't explicit support for this scenario (e.g. defining template files), but this hidden support is very useful for my case where I have several projects each needing help with common properties (e.g. keeping the Copyright property up to date., setting output languages, etc.)

Thanks for this hidden feature!

Coordinator
Sep 30, 2010 at 2:14 AM

Interesting.  I knew you could import projects but I didn't know it would let you modify properties if they originated from the imported project.  I suppose that could be related to how SHFB sets the properties.  As I recall, the ProjectGuid should be unique in each project.  SHFB creates a new value in each one it creates as does Visual Studio as far as I know.

Eric