21.03.2012 – Sergiy Nikitin

Powershell deployment and activation script enables old feature code

When you use powershell cmdlet to reinstall and activate your solution and features within it, you may experience a situation when features get deactivated and solution is uninstalled and removed smoothly. Then you add a solution, install it and activate features also without any exceptions or warnings, but you get your old feature version working!

Look at the cited explanation below: Why? Because when a process loads an assembly from the Global Assembly Cache, it will keep using that version of the assembly for the rest of its life even if a new version has later been added to the GAC. Solution deployment is run by the SharePoint 2010 Timer service, and features are activated within your PowerShell process. So if something you’ve done earlier has caused one of these processes to load the assemblies you’re updating, an old version of your code will be used during solution deployment or feature activation.

The solution is to restart the timer service, and launch new PowerShell processes, whenever you require the latest version of an assembly to run.

The answer is taken from here.

Inno-W mark
Sergiy Nikitin
Sergiy Nikitin

Posts by Sergiy