Click here to Skip to main content
15,883,883 members
Articles / Productivity Apps and Services / Sharepoint / SharePoint 2013
Tip/Trick

Sharepoint 2013 : Module is not visible to add in feature

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
1 Aug 2016CPOL2 min read 8.5K   1
if you not able to deploy custom module, below trick will help.

Introduction

There are limitation with adding custom sharepoint element at verious scope. Which can be overcome hence this article is helpfull.

Scenario

I was working with Sharepoint(2013) Web Template, for which there is no default template in visual studio. Hence i have used Module for it. I was expecting it on Farm level and i faced problem. Module are not available to deploy to Farm level feature by default. 

Which element fall into which scope?

There are 4 scopes, Web (Web site), Site (site collection), WebApplication (Web application) and Farm (farm). Below i have mentioned which elements fall under which scope by default.

[Reference below]

1] Web (Web site) :- Content Type, Content Type Binding, Control, Custom Action, Custom Action Group, Custom View, Event, Field, Hide Custom Action, List Instance, List Template, Module, Property Bag, Workflow Actions, Web Template.

2] Site (site collection) :- Content Type, Content Type Binding, Control, Custom Action, Custom Action Group, Event, Field, Hide Custom Action, List Instance, List Template, Module, Property Bag, Template Association, Workflow, Workflow Actions, Workflow Association.

3] WebApplication (Web application) :- Control, Custom Action, Custom Action Group, Document Converter, Hide Custom Action, Template Association, Web Template, Workflow Association.

4] Farm (farm) :- Control, Custom Action, Custom Action Group, Hide Custom Action, Template Association, Workflow Association.

So as above in farm scope we cant deploy module, but my requitment is to push Web Template via module using Farm scope.

Trick/Fix

1] Add module in your project and click on show all files option in solution explorer at upper right corner.

2] Now you can see your module which have sample.txt, element.xml, SharePointProjectItem.spdata. 

Now you just have to update "SharePointProjectItem.spdata" file. I renamed sample.txt to one.xml and edited as per my requirment.

3] (Carefully) Open SharePointProjectItem.spdata file [Do not copy past this code, just update you attributes]

XML
<!-- Content of SharePointProjectItem.spdata file -->
<ProjectItem Type="Microsoft.VisualStudio.SharePoint.Module" DefaultFile="Elements.xml" SupportedTrustLevels="All" SupportedDeploymentScopes="Web, Site" xmlns="http://schemas.microsoft.com/VisualStudio/2010/SharePointTools/SharePointProjectItemModel">
  <Files>
    <ProjectItemFile Source="Elements.xml" Target="ContentSubsiteTemplate\" Type="ElementManifest" />
    <ProjectItemFile Source="onet.xml" Target="ContentSubsiteTemplate\" Type="ElementFile" />
  </Files>
</ProjectItem>

Check few attributes of this file.

a) SupportedDeploymentScopes :- You can edit it to enable diffrent scope. I edited it as below :

XML
SupportedDeploymentScopes="Web, Site"

To 

XML
SupportedDeploymentScopes="Web, Site, WebApplication, Farm, Package"

Now it is available for me to deploy at Farm scope. 

b) Type :- This attribute indiate type of element template. To push my web template, so i edited it as below :

XML
Type="Microsoft.VisualStudio.SharePoint.Module"

To

XML
Type="Microsoft.VisualStudio.SharePoint.GenericElement"

Now, Go to your feature and check for this module it will be visible to deploy using your feature.

Points of Interest

This is an attribute change to make it available for other scopes. Here this module now available for all scopes. This trick only showcase stuff for module and do not cover how to create/deploy Web Template. 

Thanks

Hope it help, I'm happy to help. 

References

https://msdn.microsoft.com/en-us/library/office/ms454835(v=office.14).aspx

 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionWas looking for way to get files into features Pin
Member 1396299012-Sep-18 22:55
Member 1396299012-Sep-18 22:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.