A couple of weeks back I posted an article on how to remove missing features from a content database when you receive the [MissingFeature] error in the SharePoint Health Analyzer. I have since received quite a few requests on how to resolve the [MissingSetupFile] error, which also appears in the Health Analyzer under the “Configuration” category with the title “Missing server side dependencies”:
The error message reported will look similar to this one:
[MissingSetupFile] File [Features\ReviewPageListInstances\Files\Workflows\ReviewPage\ReviewPage.xoml] is referenced [1] times in the database [SharePoint_Content_Portal], but is not installed on the current farm. Please install any feature/solution which contains this file. One or more setup files are referenced in the database [SharePoint_Content_Portal], but are not installed on the current farm. Please install any feature or solution which contains these files.
Easily the best way of resolving these issues is to do as the error suggests and install the missing feature or solution, but if this is not possible or feasible to do in your scenario, there are some ways of using PowerShell to locate the source of the error in the content database and act on it accordingly.
There isn’t really a silver bullet to resolving the issue in all cases as the error could be referring to themes, files, workflows, web parts, and more. The key here is to find the file that references the missing setup file and then deal with it appropriately. Since we don’t know which site contains the file from the error message reported in the Health Analyzer, the best way I have found to diagnose the issue is to examine the content database using a SQL query in order to locate the file reporting the problem.
To help with this, I have adapted a PowerShell script from “Jelly” in this article (thanks Jelly) and created the following function:
function Run-SQLQuery ($SqlServer, $SqlDatabase, $SqlQuery)
{
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server =" + $SqlServer + "; Database =" + $SqlDatabase + "; Integrated Security = True"
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = $SqlQuery
$SqlCmd.Connection = $SqlConnection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$DataSet = New-Object System.Data.DataSet
$SqlAdapter.Fill($DataSet)
$SqlConnection.Close()
$DataSet.Tables[0]
}
After you have loaded the function in a PowerShell console, you can run it by using the Run-SQLQuery command with the options relevant to your deployment. For [MissingSetupFile] errors, you need to run a SQL SELECT query on the “AllDocs” table in the content database exhibiting the problem. For example, you would type the following command to examine the location of the “Features\ReviewPageListInstances\Files\Workflows\ReviewPage\ReviewPage.xoml” file reported in the [MissingSetupFile] error at the top of this article:
Run-SQLQuery -SqlServer "SQLSERVER" -SqlDatabase "SharePoint_Content_Portal" -SqlQuery "SELECT * from AllDocs where SetupPath = 'Features\ReviewPageListInstances\Files\Workflows\ReviewPage\ReviewPage.xoml'" | select Id, SiteId, DirName, LeafName, WebId, ListId | Format-List
To run this in your environment, replace “SQLSERVER” with the name of the SQL server hosting your content databases, “SharePoint_Content_Portal” with the name of the content database, and the file path in the SELECT query with the path of the missing setup file reported in the Health Analyzer (make sure this file path is enclosed in single quotes as shown above).
When the script is run, it will produce an output similar to the text below:
Id : f5fc66e7-920a-4b44-9e3d-3a5ab825093f
SiteId : 7b4d043c-8bbe-4068-ad91-3c270dfae151
DirName : subsite/Workflows/Review Page
LeafName : Review Page.xoml
WebId : 1876be06-419f-46fb-a942-a15e510f1a70
ListId : a04dda01-a52d-4d5b-b3b4-fcd70a05e4ba
Now we have the SiteId and WebId, we can use them in a few lines of PowerShell script to display the URL of the site containing the problem file:
$site = Get-SPSite -Limit all | where { $_.Id -eq "7b4d043c-8bbe-4068-ad91-3c270dfae151" }
$web = $site | Get-SPWeb -Limit all | where { $_.Id -eq "1876be06-419f-46fb-a942-a15e510f1a70" }
$web.Url
In case it isn’t clear from the “DirName” value reported from the SQL query output, you can also use PowerShell to get the URL of the actual file causing the issue by calling the “Id” field of the item:
$file = $web.GetFile([Guid]”f5fc66e7-920a-4b44-9e3d-3a5ab825093f”)
$file.ServerRelativeUrl
Now you have to decide what to do with the offending file. In the case of the error I reported at the top of this article, the file came from a workflow deployed to the site using a feature, which was not deactivated from the site prior to removing the solution from the farm. Therefore, to solve the issue I just used SharePoint Designer to remove the workflow from the site. In the case of web parts, removing web parts from the page reported in the Health Analyzer may solve the issue. Once you have dealt with the problem file, you should now be able to reanalyse the “Missing server side dependencies” issue in the Health Analyzer to clear the problem.
Please note that if you do decide to delete a workflow or a file from the site, remember to remove the file from the site Recycle Bin and Site Collection Recycle Bin to ensure the file is removed from the content database. If not, the error may not disappear from the Health Analyzer.
If you found this article looking for information on how to diagnose MissingFeature issues in the SharePoint Health Analyzer, rather than the MissingSetupFile issue, then have a look at this article for help. For information on troubleshooting MissingWebPart and MissingAssembly errors, take a look at this article.
Really great article !
ReplyDeleteI have created an automated script based on your input.
http://etienne-sharepoint.blogspot.com/2011/10/solving-missingsetupfile-errors-from.html
Thanks again Phil.
Nice work, Etienne!
ReplyDeleteSo, I get the 'MissingSetupFile' message a lot, related to one of my custom solutions that was once deployed on a sub-site that has now been totally obliterated. Thus, the $WebId variable that I get returned from the SQL query is always 00000000-0000-0000-0000-000000000000
ReplyDelete(was also getting this for EventReceivers)
Is it safe to just delete the records from the AllDocs table or the EventReceivers tables if the WebId is blank?
Helped me a lot. Thanx so much.
ReplyDeleteFollowing your steps, I have removed all offending files from Sharepoint designer and reanalyze, but the message still exists in Health Analyzer.
ReplyDeleteDoes anything I can do to remove the message? Thanks.
Similar issue as Ar Paul. What's the theory on when the changes are applied? Timer job? Re-attach content database?
ReplyDeleteSharePointWarrior
Hi,
ReplyDeleteIt's nice article. I have followed the steps as mentioned. But when I try to delete the masterpagefile, I was getting an error "This item cannot be deleted because it is still referenced by other pages". In this scenario, how do I remove those references before deleting the master page? Please help me on this.
-Prakash
what if the page/web, which referencing missing setup file, is also missing?
ReplyDeleteJust FYI: As with the last poster, there is a reference in a missing file on one and the other is the site home page which does not at all reference the deleted webpart. At this point I'm going to have to throw in the towel on this one and just ignore this error until I have more time to come back and revisit it. However if this helps anyone diagnose the issue, I created a custom web part in VS2010 to fish data out of an external data source and render it on the home page. Because I had no dev environment and this new instance of SharePoint is currently pre-migration, I have been testing the web part on the production server. Regardless of anyone's opinion on dev best practices, this was my only option. As such, I had to test, observe results, and then modify to correct issues on my production server. Part of that process was retracting/uninstalling the web part and then redeploying.
ReplyDeleteI also renamed the webpart at one point and redeployed. I think this is where the problem began. Currently I can redeploy the web part under the old name and it will resolve the problem, but it will leave an unusable web part in my web part gallery. This is not acceptable. So I would just end up retracting/uninstalling the web part, and then deleting the .webpart file from the web part gallery which will only result in the same error.
I followed the instructions of this article all the way up to $file.ServerRelativeUrl. Unfortunately, nothing is returned. There simply is no file to reference.
Trying to find anything regarding the mention of my old web part in the site file (which has to be home.aspx, the only file I was modifying), I ran the SQL Query from the Missing Web Part article and confirmed that it's indeed referenced by the SitePages/Home.aspx file. However, this isn't true at all. The webpart was deleted from that web page.
Id :
SiteId :
DirName :
LeafName :
WebId :
ListId :
tp_ZoneID :
tp_DisplayName :
Id : b0235deb-5dc2-4043-90d4-3d4c016d8228
SiteId : 806c2cee-ca06-4b6c-889c-479a6f215fff
DirName : SitePages
LeafName : Home.aspx
WebId : 36b7368f-b2a9-4f8b-a0bf-7f2bb25baa4a
ListId : da989695-227d-497a-847e-111c984f848a
tp_ZoneID : wpz
tp_DisplayName :
Feel free to follow up on this if anyone finds a viable solution. In the meantime, I'll be ignoring the alert. :(
Curious to know if anyone received this error in the powershell console after loading the initial function:
ReplyDeleteThe term 'Run-SQLQuery' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if
a path was included, verify that the path is correct and try again.
This and your other dependency resolution scripts were very helpful to me. Thanks again!
ReplyDeleteThanks Phil.
ReplyDeleteThis is an excellent article and it works with 100% accuracy.
Thanks for this series of articles - they have helped greatly.
ReplyDeleteI am down to one remaining issue, which appears to be a feature in Central Admin that is broken.
MissingSetupFile] File [Features\SPPPlatformAdminSite\SPP.aspx] is referenced [1] times in the database [SharePoint_AdminContent_7ae3762e-394a-48e2-9f02-beecaf3ed4c1], but is not installed on the current farm. Please install any feature/solution which contains this file. One or more setup files are referenced in the database [SharePoint_AdminContent_7ae3762e-394a-48e2-9f02-beecaf3ed4c1], but are not installed on the current farm. Please install any feature or solution which contains these files.
The scripts above don't seem to work the same on the Central Admin site. Any suggestions on how to clean this one up?