3

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.

Nat
  • 14,175
  • 5
  • 41
  • 64
jaloplo
  • 941
  • 2
  • 12
  • 32

4 Answers4

6

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
  • 848
  • 4
  • 11
2

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
  • 236
  • 1
  • 3
  • 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 Mar 13 '09 at 07:46
  • 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 Mar 13 '09 at 14:37
  • 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 Mar 13 '09 at 14:38
  • Ok, you convinced me with your argument. Just another question, have this job to be exectued once or is better a daily schedule?? – jaloplo Mar 17 '09 at 14:10
  • 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 Mar 17 '09 at 16:36
1

I have added a resx file to the App_GlobalResources folder by right clicking the project and choosing: - Add New Item - Empty Element called 'Resources' - Then add a new resx file to the newly created 'Resources' folder - Then on the resx file change the 'Deployment Type' to 'AppGlobalResource'

Matt

Matt Whetton
  • 6,616
  • 5
  • 36
  • 57
1

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
  • 3,473
  • 1
  • 26
  • 27