We use a feature to deploy files that are common to our webparts to the Style Library in SharePoint Server 2010 and recently we came across the problem where files were not being updated when we deployed an updated version of the feature. (Note: I use the term "version" loosely here - we are not versioning our webparts). After searching around I found that this issue (i.e. modules will deploy initial version of a file but won't update it) has been documented on a number of blogs. The conclusion of all was that to update the files, you need to do it programmatically using a FeatureReceiver. I found a couple of different solutions:
For sandboxed webpart solutions:
For farm webpart solutions:
I tried both solutions but ended up going with Johan's solution with some minor tweaks for our scenario.
I encountered a NullReferenceException when I ran Johan's code, but this was because we don't have a Path attribute on our Module element. I replaced the call to retrieve the Path attribute with a call to retrieve the Url attribute. I then encountered the following error:
The URL ‘[url]‘ is invalid. It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web
I've found various different blogs outlining solutions for this error but none have resolved it for me:
* links removed as I am but a lowly newbie who can't post more than 2 links ;) *
Does anyone have any other suggestions aside from logs?
NOTE: We are using a farm solution, not a sandboxed solution.