Failed to instantiate file "ContentQueryMain.xsl" from module "XSLStyleSheets": The specified list does not exist.
When deploying a custom branding solution to one of our customer's environments, we ran into "Failed to instantiate file "ContentQueryMain.xsl" from module "XSLStyleSheets": The specified list does not exist." when we activated the publishing features on the site collection. After some investigation, it seemed that the ContentQueryMain.xsl should exist in a subfolder XSLStyleSheets within the Style Library (which actually gets created by this feature).
This error occurs when the publishing feature sees that there is already a Style Library and does not take the action of putting the files in there, as it assumes that the Style Library has already been created by the Publishing Features. So if you already created a Style Library without the publishing features, then you should either
- move that library to another location
- deploy the publishing feature on another site collection and copy the contents of that Style Library to the one within your site collection
In my case there was no Style Library though. Nevertheless, creating a new Style Libary resulted in the url being "Style%20Library1", which meant that SharePoint did find the Style Library somewhere, I was just not seeing it. Opening the site with SharePoint Designer 2010 as a site collection admin gave me the option to choose All Files to see the content of the site. And there I could see the Style Library. I renamed it to Style_Library_Error and closed down SharePoint Designer.
Afterwards, I created a Document Library called Style Library. Now the URL was showing me properly Style%20Libary.
I went back to the site collection settings, activated the Publishing Features and all was fine. Afterwards, the branding solution was properly deployed and yet another happy customer :)