Compiling Resource file in a PreCompiled web site at the production server
So you have a precompile web site located on the customer's production server and you want few of the following:
- Allow the customer IT / PS to alter the resource you are using (without your help)
- Create a simple mechanism of updating the resource file without distributing a DLL.
To do a task like this you would probably create a provider for the localization and start coding you way threw the solution, I suggest another approach that is far more simple and doesn't require you / customer to deal with DLLs and also enable the customer's IT / PS to write an application that will enable him to edit the resource.
High Level Solution
on the production server you will have a directory that will hold all the pre compile RESX file + few utility classes that can be called in various ways (web page / schedule / exe , etc).
- For simplicity you will only update a specific culture and not natural - the reason is that i don't want to start messing with a more complex compilation of a typed resource).
- The entire localization related files will stay with a new directory.
- You will have to have a new directory that will hold the pre compiled RESX (for each culture other than the natural as said in Pr.1)
- You will have to create a batch file / VBS that will do all the compilation and moving of the new resource.
- Create a new directory called "LocalizationKit" (This is for simplicity)
- Create a new directory under "LocalizationKit" called "Utilities" - this directory will hold all the files needed to compile the resource at the production server.
Copy the following files to this directory:
- On your post build event create a task that will copy each resource (related files) to a new directory under "LocalizationKit" based on the culture name (E.g. en-US, en-GB, etc)
- Create a batch / VBS file that will do the following for all the resources:
- Convert the RESX file to .resources using resgen (E.g. Resgen.exe [file.resx])
- Compile the relevant .resource files to one DLL (E.g. al.exe /nologo /t:lib /embed:[resource], [file name] /culture:[RESX culture] /out:App_GlobalResources.resources.dll
- Copy the newly created resource DLL to the relevant directory under the bin (E.g. ..\Bin\en-US\) [Make sure that the directory exist, if not than create it]
- Delete the ".Resource" file (not needed)
Now all that you have to do on your production server is to alter the relevant RESX file in the "LocalizationKit" directory and call the method before.
Using this solution you can give the customer the option to change keys in the resource without needing you / new code.
Hope this help you (if you want a sample directory mail me).