Ive created a very simple custom site provisoning provider as a test and im having some problems and cant figure out why. Basically at this moment all the site provisioner does is enable publishing at the site collection level and the site level. However it errors out stating that "The SharePoint Server Publishing Infrastructure feature must be activated at the site collection level before the Publishing feature can be activated.". Ive commented out the code that enables the feature at the site level and verified that the publishing feature is actually enabled when i create a new site collection from my template.
Any ideas as im stumped
props.Web.ApplyWebTemplate("PROJECTSITE#0");
SPSecurity.RunWithElevatedPrivileges(() =>
{
using (SPSite siteCollection = new SPSite(props.Web.Site.ID))
{
using (SPWeb web = siteCollection.OpenWeb(props.Web.ID)){
siteCollection.Features.Add(new Guid("f6924d36-2fa8-4f0b-b16d-06b7250180fa"));
web.Features.Add(new Guid("22a9ef51-737b-4ff2-9346-694633fe4416"));
}
}
});