Confused by role of Type attribute in Extensions

Feb 19, 2014 at 4:54 AM
Hi

I am a little confused by the role of the Type attribute in the new Extensions add-on.

Probably not coincidently, it took me a while to get all the moving pieces together to add my own extensions for feature activation, etc.

I think maybe a diagram showing how all the pieces interconnect would help.
Coordinator
Feb 19, 2014 at 1:49 PM
I understand. Have you read my blog about building extensions http://www.matthiaseinig.de/2014/01/05/building-your-own-extension-for-spsd/?

The type is used to reference the extension in the environment XML.
This is necessary as you could have multiple "instances" of the same extension in the same deployment.

So the IDs will identify the instance and the type the extension.

For example, I have built an extension which backups/imports terms from/to the MMS.

So I would reference the same extension twice with different configuration files
<SPSD Version="5.0.3.6438">
  ...
  <Extensions>
    <Extension ID="MMSBackup" Type="MMS" FilePath="Extensions\Backup.xml" />
    <Extension ID="MMSImport" Type="MMS" FilePath="Extensions\Import.xml" />
  </Extensions>
</SPSD>
You can even have both IDs in the same referenced file if you like, but I prefer separating them.

BTW, the "FilePath" attribute works on every XML node in SPSD.
This allows you also in the extension configuration to refer to a separate file.

For example I have an extension building up a site structure based on an XML in the <Data/> of the extension.

Now when I want the same site structure to be created on several webapplications (for whatever reasons ;) ) with different parameters, I am just creating two extensions.xml files with the different parameters and reference the same data.xml from like this

SiteStructure1
<SPSD Version="5.0.3.6438">
  <Extensions>
     <Extension ID="SiteStructure1" Type="SiteStructures">
      <Events>
         <Event Name="AfterDeploy">Create-SiteStructures</Event>
         <Event Name="BeforeRetract">Delete-SiteStructures</Event>
      </Events>
       <Parameters>
        <Parameter Name="WebApp">$(WebApplication)</Parameter>
        <Parameter Name="ContentDB">DB1</Parameter>
      </Parameters> 
      <Data ID="SiteStructureData" FilePath="Data.xml"/>
    </Extension>
  </Extensions>
</SPSD>
SiteStructure2
<SPSD Version="5.0.3.6438">
  <Extensions>
     <Extension ID="SiteStructure2" Type="SiteStructures">
      <Events>
         <Event Name="AfterDeploy">Create-SiteStructures</Event>
         <Event Name="BeforeRetract">Delete-SiteStructures</Event>
      </Events>
       <Parameters>
        <Parameter Name="WebApp">http://webapplication.com</Parameter>
        <Parameter Name="ContentDB">DB2</Parameter>
      </Parameters> 
      <Data ID="SiteStructureData" FilePath="Data.xml"/>
    </Extension>
  </Extensions>
</SPSD>
The Data.xml then has all the necessary details about the structure
<SPSD Version="5.0.3.6438">
  <Extensions>
     <Extension>
      <Data ID="SiteStructureData">
        <Sites>
           <Site Title="abc" url="${WebApp}" contentdb="${ContentDB}">
              <Sites>
              ....
              </Sites>
           <Site>
           ....
       </Sites>
      </Data>
    </Extension>
  </Extensions>
</SPSD>
As you see the data can be re-used as it uses the parameters but it can be built with the same extension of type "SiteStructures" at two different places.
Hope that gives some clarification and ideas.
Feb 20, 2014 at 1:00 PM
Following on from that, the Type appears to identify the script. Am I right in saying that there is a one to one relationship between Type and script name?

I think I got confused because I assumed Type implied category, so making it a one to many relationship
Coordinator
Aug 29, 2014 at 9:25 AM
Sorry, I seemed to have missed your reply.
Yes, you are right, there is a 1:1 relation between type and scriptname.

You can find some example extensions along with the rest of the source here https://github.com/rencoreab/SharePoint-Solution-Deployer/tree/master/SPSD.Editor