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.