I am working on a major version release for the end of this year, some of our webparts are being moved from one namespace to another, and from one WSP into another, new feature id's etc.
So I created a simple windows application, added a couple controls to it, it does the following:
- Goes through all our web applications
- Looks for sites with the old feature
- In those sites, looks for out specific "old" webparts on pages
- Records these pages to a file
- Records which web parts were being used
- Then removes the webparts from the page
- Turns off the old feature
- Then removes the webparts from the gallery (just to be sure they are gone!)
A little deployment work-
Retract the wsp, remove it, update our file from SVN, install, and deploy the new/updated solution.
Then open the application back up:
(click on button 2 this time IMPORT), pick a file,
Go through the list of sites in the file, turn on the new features (which will create the webparts in the gallery for us)
Then loads each of the pages we removed parts from before, and it creates new webparts and adds them to the pages.
NOW, one of the webparts I planned to add to the page, always threw an exception. Everytime I created an instance of the object with this application it died. So, I went to the class causing problems, and apparently in the constructor, there was a line...
m_currentWeb = SPContext.Current.Web;
I want to hit something, first of all, there should not be a reference to SharePoint in the constructor, especially not something using SPContext, becuase, it can never be used outside of an application running IN SharePoint. BAH. Moved the line into the CreateChildControls override and life is all good again.
The application finishes up, and our old webparts are replaced by our new ones. Ah another working application to save me time.
(manual work 10%, automated 80%, dubgging problems across projects and solutions, priceless!)
Now to gather publishing state of pages, so we do not have to manually approve all the already approved pages... here comes v2.0!