I've managed to deploy a new master page via a feature developed in Visual Studio (as per Deploying a custom master page in SharePoint 2010). However, while the files are copied to the SharePoint site, they are in 'draft' status, so as a result the new MasterPage won't work for regular users until the files have been approved/published.
Originally when the feature is activated, the MasterPage is set to the new MasterPage, but because of the 'draft' status, I had to turn off that functionality. That means I have to activate, then publish each file, which is cumbersome, especially if I want to apply it to more than one site and I ever update the MasterPage or related files.
How can I auto-publish the files that have been deployed as part of the solution. Through code (C# FeatureActivated
) I presume, since I haven't seen any xml attributes I can use in the elements.xml that can do this.
Additionally, after removing the solution, is it possible to delete the files from the site as well (the MasterPage is set back to its previous开发者_StackOverflow社区 setting when the feature is deactivated)?
Please see my answer at SharePoint.SE.
The LayoutsFeatureReceiver
For deleting, implement the FeatureDeactivated event, and use
file.RevertContentStream();
to undo any edits to existing layouts
精彩评论