Home > PowerShell, SharePoint, SharePoint 2010 > SharePoint 2010 Bug: Using PowerShell to reinstall solution files may reinstall old assemblies

SharePoint 2010 Bug: Using PowerShell to reinstall solution files may reinstall old assemblies

I wrote some PowerShell scripts to automate the deployment of SharePoint solution files (WSPs) and the creation of a site structure including test content defined in an XML file.

In order to tear down and reinstall a development environment quickly, I also automated the deletion of the site collections and retract and uninstall the solution files.

The problem happened when I put all of these scripts together to delete the site structure, retract and uninstall the old solutions, install and deploy the new solutions, and recreate the site structure, all from one script. I found that even though the new solution files were referenced to install and deploy, bug fixes or changes to feature receivers never seemed to take effect as though the code was never changed.

After experimenting for a while I found that the new assemblies in the updated WSPs were definitely not being used and the old assemblies were in fact being reinstalled!

I found 2 resolutions to this:

  • Ensure that the AssemblyVersion is updated before build and deployment, so the latest version will always be deployed. One problem with this approach is that you will have to reinstall all assemblies otherwise assembly references will break if they are not all rebuilt and deployed together. This approach cannot be used if you will be required to deploy as a patch.
  • Close the PowerShell session and start a new one in between uninstall and reinstall of the solution files. For some reason this always uses the latest assemblies deployed from the latest solution file even if the AssemblyVersion remains unchanged.

It is not clear why this problem happens only while using the same PowerShell session (using the SharePoint PowerShell snapin) so I now use a command file to launch each PowerShell script in separate PowerShell sessions and never get this problem any more.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: