I have a site definition with a custom web part, the projects (both the site definition and the web part) are part of a CI build which means the version numbers are incremented each build.
The process is as follows:
- The web part assembly changes each build
- The site definition has the correct version of the web part defined in the onet.xml file.
- The sites using the Site Definition are only ever created if the site is not present as part of the build.
- When browsing the site (after a new build) each of the web parts is showing an error:
My thoughts are that I will have to write a script as part of the build that will loop through each page in the sites using the custom site definion and replace the references for the old web part assemblies for the new ones, is this correct? is there a simpler way of doing this?
I've tried "Reset to Site Definition" but this didnt work - other than an IIS Reset does this require a server reboot too?
Web Part Definition in onet.xml
<AllUsersWebPart WebPartZoneID="WP_Zone_Top_Right" WebPartOrder="1">
<![CDATA[
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="$(NameSpace), Version=$(VersionNumber), Culture=neutral, PublicKeyToken=$(PublicKey)" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<!-- properties removed -->
</properties>
</data>
</webPart>
</webParts>
]]/>
</AllUsersWebPart>
The webparts are created using ASCX user controls which are then instantiated by the actual web part.
The namespace, versionnumber and public key are set at build time. If the sites are not created then no error is displayed (the web part is correctly rendered) the the sites exist though then the error saying that the web part is not registered as safe or cannot be found is displayed.
The web part is also re-deployed as part of the same build by doing a full cycle of:
- Deactivate
- Retract
- Uninstall
- Install
- Deploy
- Activate