Sharepoint - Error occurred in deployment step 'Recycle IIS Application Pool': Object reference not set to an instance of an object

I had the same problem today. I compared the project files with an older version. In my case the Package directory (with the files Package.package and Package.Template.xml) was missing.

After copying this directory back from the older version of the project and modifying the csproj file to include the references to the package directory, the error solved and the solution can be deployed again.

I added the following settings to the csproj file to restore the binding to the package directory.

<ItemGroup>
...
    <None Include="Package\Package.package">
      <PackageId>{03851424-152b-45c0-80c9-ac18975dc663}</PackageId>
    </None>
    <None Include="Package\Package.Template.xml">
      <DependentUpon>Package.package</DependentUpon>
    </None>
...
</ItemGroup>

Something similar could be the problem in your situation.


A few suggestions:

  • Make sure your solution builds (without deployment) without errors. F6

  • If not, check that your solution is set to build on Any CPU

  • If not, check that you don't have logical programming errors in your solution

When the solution builds:

  • Check your pre- and post- deployment steps ALT + ENTER

  • Still doesn't work? Validate your solution deployment URL

  • Still doesn't work? Uninstall and remove your solution from the farm using Uninstall-SPSolution and Remove-SPSolution cmdlet. Make sure all of your features are gone from the farm with Get-SPFeature cmdlet