SharePoint 2013 Troubleshooting: Add-SPSolution - The solution cannot be deployed.

Problem

I was engaged in upgrade testing of a legacy customer SharePoint 2010 farm to SharePoint 2016, exploring potential upgrade issues involving a third party solution, call it "TPS1." The overall upgrade test I was engaging in was something like this:

SharePoint 2010 Prod Farm SharePoint 2013 Dev Farm SharePoint 2016 Dev Farm
content database > content database > content database
TPS1 (2010) > TPS1 (2010) > TPS1 (2013) > TPS1 (2013) > TPS1 (2016)

I mounted a copy of the production SharePoint 2010 content database to the development 2013 farm, and then reviewed the upgrade report. No upgrading blocking issues were found, but there were many warnings involving the third party solution, TPS1.

Reviewing the list of installed farm solutions in Central Administration on the 2010 development farm, I found that an older version of TPS1, though it had been successfully uploaded, had not been successfully installed to the web applications in the development farm. So, I needed to remove all traces of that older solution version so that when I performed the mount of the 2010 content database to the 2013 farm, any TPS1 features and web parts deployed in the 2010 content database would automatically sync with the solution and would not generate any upgrade warnings.

Since it didn't seem to ever have been actually deployed, I first tried removing the solution by executing this commandlet:

Remove-SPSolution -Identity "TPS1.wsp"

This commanded completed successfully, and, checking the installed solutions list in Central Administration, I no longer found TPS1 listed. I then downloaded the latest build of the SharePoint 2010 version of TPS1.wsp and attempted to upload it to the 2013 dev farm by executing:

Add-SPSolution -LiteralPath "D:\Temp\TPSA1.wsp"

This commandlet did not complete successfully, and the following error message was displayed in the shell after it failed:

Add-SPSolution : The solution cannot be deployed. The feature '[SomeFeatureID]' uses the directory "[SomeDirectory2]" in the solution. However, it is currently installed in the farm to the directory "[SomeDirectory1]". Uninstall the existing feature before you install a new version of the solution.

This was new to me so I began troubleshooting.

Troubleshooting Steps

  1. I first looked in the features folder, 15\TEMPLATE\FEATURES, for "SomeDirectory1."

    • Not found
  2. I then searched more generally in \15\TEMPLATE for "SomeDirectory1."

    • Found it under ...\15\TEMPLATE\FEATURES\ADMIN\SomeDirectory1. Looking in the folder, I found it empty.
  3. Next, pulled a listing of all features across the farm by executing 

    Get-SPFeature | sort-object DisplayName | ft Displayname,ID -auto
    
    • Found a listing for "SomeDirectory1 SomeFeatureID"
  4. Pulled listing of all orphaned features by executing 

    Get-SPFeature | ? { $_.Scope -eq $null }
    
    • Found a listing for "SomeDirectory1 SomeFeatureID".
  5. Attempted to get a reference to the orphaned feature by using 

    $feature = Get-SPFeature -Identity '[SomeFeatureID]'
    
    • However, executing this commandlet returned the following error message:
  6. Get-SPFeature : Cannot find a Feature object with Path or Id: '[SomeFeatureID]' in scope Local farm.

  7. Attempted to get reference to the orphaned feature through its display name using 

    $feature = Get-SPFeature | ? {$_.DisplayName -eq "SomeFeature"}
    
    • Executing this commandlet resulted in the feature information being displayed. This was good. If I could get an instance of the feature, I could execute its delete method.
  8. Attempted to delete the feature by executing 

    $feature.delete
    
    • This returned nothing. This was also good.
  9. Just to be sure, I pulled listing of all orphaned features by executing 

    Get-SPFeature | ? { $_.Scope -eq $null }
    
    • Feature is not listed. This indicated that the orphaned feature was completely removed.
  10. Now attempted to upload the most recent build of the solution by executing 

    Add-SPSolution -Path "D: \2010\TPS1.wsp"
    
    • Succeeded.

Solution

  • Check for orphaned features if unable to upload newer versions of third-party solutions.

References

Notes

  • Thanks to Anatoly Mironov for pointing the way to the solution. His clear description helped me quickly identify and resolve the problem.