While I am on the topic of SharePoint solution upgrade, here is the scenario:
My solution is going through an iterative development process. I use themes to enforce the look and feel of my site. Each site (SPWeb) in my solution has a feature in it’s definition which sets the theme for that site. My solution structure has been created a while ago, now I’m in a process of upgrading style definitions in my theme etc.
When theme solution gets upgraded – the features provisioning new theme get redeployed and new artifacts also get copied to the file system; however – new CSS changes which came in the upgraded version are not picked up.
SharePoint makes a database copy of certain artifacts in your theme, CSS is one of them. The database version remains the same unless, after your upgrade, you chose to change the theme to some other theme and then reset it back. However, this operation has to be done on each of the sites (SPWeb) in order for new changes to be picked up on each of the sites. This can be done through the UI of course, however, if you have complex structure – it’s often not feasible.
As an approach below code can be executed to reset your theme. The snippet below is an application page part which resets the theme – so that user gets a long-running-operation UI; however you can execute the same logic in a feature receiver or console application:
string themeName = "MyThemeName";
string comeBackUrl = HttpContext.Current.Request.Url.ToString();
using (SPLongOperation operation = new SPLongOperation(this.Page))
{
operation.Begin();
if (!string.IsNullOrEmpty(themeName))
{
foreach (SPWeb web in this.Site.AllWebs)
{
using (web)
{
web.ApplyTheme(themeName);
}
}
}
operation.End(comeBackUrl, Microsoft.SharePoint.Utilities.SPRedirectFlags.DoNotEncodeUrl , HttpContext.Current, null);
}
Thinking long term, you probably want to have this code executed as an application page – so that your SharePoint administrator can call it when you upgrade your theme some time in the feature.
Good Luck!