views:

2767

answers:

3

Hi everybody,

I've made a lot of solutions (wsp) for SharePoint 2007 and I have almost automated all installation steps needed, but there is one thing I cannot automate.

How can I make a solution that places resources (resx) files in the App_GlobalResources folder of the virtual application?

Thanks in advance.

+6  A: 

You'll need to write a Feature Receiver that copies the files, because there's no way to deploy them directly through SharePoint configuration files.

I found this blog post useful when I had to do this: SharePoint Resources, Types, Use and Deployment

DylanW
+2  A: 

The solution framework don't support deployment to the App_GlobalResources folder.

You need to write a SharePoint timerjob that copies the files. A timerjob runs on all servers i the farm, so every server will get the resource files copied. What you should be aware of is the context (Domain account) you run your timerjob. To start the timerjob you need to use a farm account - the account who runs the web application isn't enough (This includes RunWithElevated...) - long story short - start the timerjob from af Farm feature or a hidden SiteCollection feature (Hidden features runs as the farm account).

Find more inspiration here:

Creating Custom Timer Jobs in Windows SharePoint Services 3.0

SharePoint Resources, Types, Use and Deployment (The link DylanW referred to)

Brian Jensen
Don't you think that a timerjob is not the right solution? Like it's said here this solution is like using gunfire to kill flies (sorry for the translation from spanish to english).
jaloplo
In a single server setup you can just write some code to copy the files directly in the feature receiver. But in a multi server setup, the only way you can make sure the resource files get's copied on every server is with a timerjob
Brian Jensen
as a timerjob runs on every server and the code only runs on the server the feature is activated on. There is a alternative solution, where you use feature stapling (also mentioned in the SharePoint Resources, Types, Use and Deployment link) - but i think a timerjob i the best solution for the job.
Brian Jensen
Ok, you convinced me with your argument. Just another question, have this job to be exectued once or is better a daily schedule??
jaloplo
Once should do the trick - However, if you update your resource files then they won't get copied (as the timer job won't run). So make a feature you can deactivate/active without any trouble, so that you can control the action
Brian Jensen
+1  A: 

You could use the stsadm command CopyAppBinContent that copies files frpm 12/Resources to App_GlobalResources. So your WSP (VS project) need to place your resx files in that folder. I´m using a solution where I actually place my resx files in a folder called Resources in the .csproj root (just to avoid the weird namespaces that come with placing them in 12/Resources) and then XCopy them (the resx files) to 12/Resources when I build.

CopyAppBinContent is then added to the deploy process (a step in a .bat file).

CopyAppBinContent has some issues when run on a farm and to come around that I use a custom SPJobDefinition that handles starting that command in the farm.

Johan Leino