Wednesday 2 December 2015

SharePoint : Resource File Deployment

SharePoint : Resource File Deployment

 
Deployment of resource files with SharePoint has always been a little tricky. With MOSS we used features to provision resource files. With SharePoint 2010 it was a little easier but not enough.
There are blogs with some ideas how to make it easier to deploy resources in multiple Locations  They did not anyways fill all my requirements.
I do not want to:
1. Use feature to deploy resources
2. Keep two copies of the same resource file in the project
3. Edit the manifest.xml in visual studio.
4. To have “Resources” subfolder inside App_GlobalResources folder.
With the help of the blog post above, I managed to create solution where you only keep one copy of the resource file and that it is easy to manage and easy to deploy to the whole farm.
Add a mappedfolder to your project and point it to 14\Resources folder. Then add your custom resource file(s) to it:

Add a Empty Element to your project and name it App_GlobalResources:

Delete the feature it created automatically, you will not need it:

Delete the Elements.xml file it automatically created, you will not need that:

Edit the SharePointProjectItem.spdata file inside the App_GlobalResources folder (If you cannot see it, press “Show All Files” button from the Solution Explorer). Replace the empty
<Files />
node with the following xml, with your own path and file name:
  <Files >
    <ProjectItemFile Source="..\Resources\EasyResource.en-US.resx" Type="AppGlobalResource"/>
    <ProjectItemFile Source="..\Resources\EasyResource.fi-FI.resx" Type="AppGlobalResource"/>
    <ProjectItemFile Source="..\Resources\EasyResource.resx" Type="AppGlobalResource"/>
  </Files>
If you add new resource files later remember to update this file too.

Double click the Package folder and add the App_GlobalResource item to the Package:

Build and deploy, all resource files will be deployed to 14Hive and WebApplication.
14Hive:

WebApplication:

When editing the resource files, just a normal Update-SPSolution command with PowerShell will update the resources to the whole Farm. I hope this helps someone struggling with the manual copies or other hacks with deployment of resource files.

Ref: http://www.sharepointblues.com/2012/05/28/sharepoint-2010-resource-file-deployment-done-easy/

No comments:

Post a Comment