We have an web-level feature that when you activate it will change the master pages used by the web to point to a .master page in the rootweb of the site collection.
This feature has been activated on a particular web, and worked (i.e. our new master page is in use). The web was then saved as a Site Template. When a new web was created using that template, the new web does not use our custom master page. Instead, it uses v4.master.
This is surprising - I thought that saving the template would persist the URL to our custom master page.
Also, the feature is showing as being Activated for the new web. However, attaching to the process in Visual Studio, the FeatureActivated method is not called during site creation. If I manually deactivate and reactivate the feature, my breakpoints in Visual Studio are hit.
I did download the site template and unzip it to check inside. In the ONET.xml file I can see my feature listed as a Feature under WebFeatures.
Therefore:
- My Master Page URLs aren't persisted in the Site Template. Is this because they are from outside the site itself?
- The Site Template does seem to know about my web level feature...
- ...and shows it as active, but the FeatureActivated code doesn't appear to be run at site creation.
- Running the code manually does show in Visual Studio, and works.
Any ideas what I've done wrong or not understood? Or is this a bug? We'd prefer our customer to be able to build their own site templates, so I'd prefer not to resort to feature stapling, and I can't understand why I'd have to.