locked
Why GlobalResources get compiled but LocalResources don't RRS feed

  • Question

  • User-568656090 posted

    When I publish my website, I notice that the App_GlobalResources are compiled but App_LocalResources are not and copied directly to output folder. I wonder what's the reason behind this design. Thanks.

    Friday, November 24, 2017 2:20 PM

All replies

  • User753101303 posted

    Hi,

    This is a web site or a web application project ? Precompiled or not ? I would have to test but my first thought is that this is because ASPX files could be compiled (and then you have placeholder files) or updatable directly on the server.

    So if you can update an ASPX file, it makes sense that you can update as well the corresponding resource files on the fly. Check maybe what you have in the corresponding files (markup or a "this is a placeholder file" sentence).

    Friday, November 24, 2017 2:33 PM
  • User-568656090 posted

    It's a Web Site project, not a Web Application. Maybe it's a misunderstanding. I do not see App_GlobalResources in published folder, but only see App_LocalResources. That's why I come to the conclusion.

    EDIT:

    Now I see I set my website to be updatable and that explains why LocalResources are copied to output folder. But why GlobalResources are compiled? That does not make sense.

    Friday, November 24, 2017 2:43 PM
  • User753101303 posted

    I'm not familiar with this model and would have to try. What if you search for a known  resource string to see if you find this in a DLL (do you have any DLL ?) or maybe in generated source code ?

    The "custom tool" settings for this file could also perhaps help to figure out what happens for this file.

    Friday, November 24, 2017 3:22 PM
  • User-568656090 posted

    I'm not asking a solution about a 'bug'. I want to know the reason behind the design why GlobalResources are so special compared to LocalResources.

    Friday, November 24, 2017 4:10 PM
  • User753101303 posted

    (shortened answer)

    global resources are always available as a strongly typed class. So it can make sense to consider them as code rather as data.

    According to https://msdn.microsoft.com/en-us/library/ms229863.aspx you might have some obscure option to still keep resx files while still precompiling the site :

    Files in the App_GlobalResources subdirectory

    These files are compiled into assemblies and placed in the Bin directory. No App_GlobalResources subdirectory is created under the main output directory. If the configuration file specifies appliesTo="All", .resx and .resources files are copied to the output directories. They are not copied if they are referenced by a BuildProvider.

    Friday, November 24, 2017 4:21 PM
  • User-707554951 posted

    Hi neo_in_matrix ,

    Unlike the root App_GlobalResources folder, App_LocalResources folders can be in any folder in the application. You associate a set of resources files with a specific Web page by using the name of the resource file.

    Accoding Table in  official document  that describes the different file types and the actions taken on them if the application is being precompiled for deployment and update.

    For .resx files in the App_LocalResources folders, copies files as is to the App_LocalResources folder of the output location.

    https://msdn.microsoft.com/en-us/library/bb398860.aspx

    Best regards

    Cathy

    Monday, November 27, 2017 6:20 AM