In the current project, the solution is already existing, the solution has like 5 features and each feature deploys different things.

The current development never used feature versions. So I suppose version is for all features.

I already made a logic change in one of the .ascx.cs files. I want to upgrade that change only.

I cant retract and redeploy the solution, that will delete lists data, etc.

I suppose I can add a version to the feature.xml that holds that file and put version Then create a feature upgrading event receiver and just call Feature.Upgrade?

How else would you do it?


2 Answers 2



The .CS code is compiled into the assembly. The actual .cs file is never deployed to SharePoint, so the only thing you would need to do is rebuild the WSP solution and upgrade it. This will update the assembly, recycle the app pool, and deploy your change to any web application.

Beyond that, Ashish is right that removing a solution will not remove created artefacts, but if you're using featuredeactivating or featureuninstalling event receivers, these will fire if you remove the solution, so it's better to upgrade when you are in fact upgrading.

Keep in mind that you cannot add new files to a solution when upgrading a WSP, but that this does not apply to .cs files because these are all compiled into one assembly in any case. So, you cannot add new features to an upgraded WSP, but you can add new class files because these will be compiled into the existing .dll.


  • so, in this case, if I execute the Upgrade-SpSolution powershell, it will be enough? Commented Feb 26, 2012 at 0:00
  • should be enough. probably recycling app pool requires; but I would do it on testing environment first Commented Feb 26, 2012 at 0:53
  • the good thing is that I have a dev environment also, so I can try it there first. So in summary, update-spsolution only works if there is no new files added to the features, it updates the dlls on the gac, so my change will be reflected, however if I add new content types, lists, etc, then another approach needs to be taken. Commented Feb 26, 2012 at 13:50
  • Esteban, upgrades won't work if you add new files, but you can add new content to existing files. So, if you add a new content type to an existing elements file, you can get away with simply reactivating that feature after upgrading. Commented Feb 29, 2012 at 21:25

When you retract the solution, it will not delete the list data. For similar changes (update code behind), I have redeployed the solution many times without any issue.

  • its strange, at the beginning I was trying to do deploy using visual studio, and then the list data is empty. Commented Feb 26, 2012 at 0:00
  • visual studio clean all stuff; PS/stsadm don't; but we assumed that you don't use VS on production environment :) Commented Feb 26, 2012 at 0:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.