Sitecore Include Files sort order broken

2019-08-08 22:40发布

问题:

Suddenly, Lucene indexes at my Sitecore website got broken and after some investigation, I've noticed that Sitecore include files are "patching" web.config in non-alphabetical order.

John West mentioned in one of hist blog posts:

Sitecore processes Web.config include files in alphabetical order (technically, the order returned by the Directory.GetFiles() method).

However, MSDN says:

The order of the returned file names (from GetFiles()) is not guaranteed; use the Sort() method if a specific sort order is required.

What could cause that kind of issues? Is it something related to the server configuration?

回答1:

I have a trick that you can use if you need to ensure that your own config include is always included after all the other include files.
Make sure all the default and vendor .config files are located directly in the /App_Config/Include folder and then create one sub folder in which you place your own include file, for example /App_Config/Include/Custom/MyConfig.config.

This way your config include is always loaded last because files from the top-level folder are always returned first by the Directory.GetFiles() method.



回答2:

Plase check this link . The order of the returned file names is not guaranteed; use the Sort() method if a specific sort order is required. it say on MSDN.

But I know when you want to patch a patch, the naming of the file is important. Example: You can patch Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config

by creating a new config file called Sitecore.ContentSearch.Lucene.DefaultIndexConfigurationPatch.config which will then be included in the final web.config section right after the original Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config.

You can check your modification on config files with :

hostname/sitecore/admin/showconfig.aspx