Sunday, January 17, 2016

Fix MissingSetupFile Error of Test-SPContentDatabase in SharePoint Migration

Problem: Getting "MissingSetupFile" errors when you run the "Test-SPContentDataBase" cmdlet on SharePoint content databases during a migration process.
[MissingSetupFile] File [Features\Feature-folder\feature-artifact] is referenced [1] times in the database [SharePoint_Content_database], 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_database], but are not installed on the current farm. Please install any feature or solution which contains these files.
sharepoint test-spcontentdatabase missingsetupfile
Root Cause:
In SharePoint migration, The source SharePoint 2010 environment sites contains references to some of the Feature files and those features are not installed in the target SharePoint 2013 Farm.

Solution:
Well, The resolutions is: Install & Deploy all solutions from the source farm to the destination farm. Your organization may have built & deployed several customization such as 3rd party products (such as bamboo solutions), custom WSP solutions, site definitions, Features, event receivers, Web Parts, user controls, etc. in the SharePoint 2010 environment and you have to install and deploy all these binaries & solutions to your destination SharePoint 2013 environment prior testing content databases for upgrade.

Deploy Solutions from Source Farm to the Destination farm:

  • Go to SharePoint Central Administration >> Navigate to "Solution Management" >> Manage Farm Solutions from System Settings of your SharePoint 2010 Farm (or any SharePoint source farm).
  • Make an inventory of all your WSP Solutions deployed to the farm. Identify the Web Applications to which these solutions are deployed to.
  • Download all WSP files and port it to the target farm. Deploy all of them in the target as per the source farm.
Instead of manually doing above steps, you can use PowerShell to automate:
  1. How to Extract & Download All WSP Solution Files in SharePoint
  2. How to Install & Deploy Multiple WSP Solutions using PowerShell in SharePoint
What if you don't need those missing feature artifacts such as web parts in your Target farm and cleanup missing setup files from the content database?

PowerShell script to find & delete missing setup files:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

Function Run-SQLScript($SQLServer, $SQLDatabase, $SQLQuery)
{
    $ConnectionString = "Server =" + $SQLServer + "; Database =" + $SQLDatabase + "; Integrated Security = True"
    $Connection = new-object system.data.SqlClient.SQLConnection($ConnectionString)
    $Command = new-object system.data.sqlclient.sqlcommand($SQLQuery,$Connection)
    $Connection.Open()
    $Adapter = New-Object System.Data.sqlclient.sqlDataAdapter $Command
    $Dataset = New-Object System.Data.DataSet
    $Adapter.Fill($Dataset) 
    $Connection.Close()
    $Dataset.Tables[0]
}

#Define configuration parameters
$Server="Ab-SQL-001"
$Database="SP10_Content_KM"
$SetupFile="Features\Crescent.Intranet.WebParts\WEFnews\WEFnews.dwp"

#Query SQL Server content Database to get information about the MissingFiles
$Query = "SELECT * from AllDocs where SetupPath like '"+$SetupFile+"'"
$QueryResults = @(Run-SQLScript -SQLServer $Server -SQLDatabase $Database -SQLQuery $Query | select Id, SiteId, WebId)

#Iterate through results
foreach ($Result in $QueryResults)
{
    if($Result.id -ne $Null)
    {
        $Site = Get-SPSite -Limit all | where { $_.Id -eq $Result.SiteId }
        $Web = $Site | Get-SPWeb -Limit all | where { $_.Id -eq $Result.WebId }

        #Get the URL of the file which is referring the feature
        $File = $web.GetFile([Guid]$Result.Id)
        write-host "$($Web.URL)/$($File.Url)" -foregroundcolor green
        
        #$File.delete()
    }
}
This script gets you all locations where the missing setup file is referenced (and optionally delete them!). Don't forget to set the variables $Server, $Database and $SetupFile appropriately!



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!


You might also like:

Related Posts Plugin for WordPress, Blogger...