/ Published in: XML
<strong>Setting up a sp .net soln</strong>
<p>File --> New --> Project</p>
<p>on lefthand side -> Sharepoint -> 2010</p>
<p>usually select an empty template</p>
<p>name the project</p>
<p></p>
<p>to add files, create a module...</p>
<p>right-click project --> add --> new item</p>
<p>select "module"</p>
<p>give the module a name (such as masterpagecatalog)</p>
<p>this will create the module, containing an elements.xml file and open the elements.xml file in code editor. Sample.txt will also be created but may be deleted.</p>
<p>Drag any previously created files that will live in the new module into the module icon in solution explorer</p>
<p>Edit elements.xml. (See example edits to elements.xml in code block further down.) </p>
<p>Edits to make to default xml:</p>
<p>in <Module> tag, put a url (such as Url="_catalogs/masterpage" ) and put RootWebOnly="TRUE"</p>
<p>The <file> tag will also be created with a default url property. Make sure to edit this so that it is correct. By default, it will create a path starting with the name of the module. And if there is no such folder already with that name beneath the Module path, the feature will create one. The actual path is designated by both the <module> url property and the <file> url property (that is, both of those properties are combined).</p>
<p>Add Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" to the <file> elements. IgnoreIfAlreadyExists="TRUE" means "overwrite existing file". Type="GhostableInLibrary" setting is used when a file is placed into a library. If a file is placed outside of a library, Type="Ghostable" would be used.</p>
<p>Change the <file> tags so that it is not self-closing.</p>
<p>Add some Property tags.Columns in the master page correspond to file object properties indicated in the module xml. Other file properties in the xml will also be added to the "property bag" that do not correspond to master page columns (see <property> tags above). </p>
<p>First, it is good practice to always add
<Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/></p>
<p>On compliation, Value="$SharePoint.Feature.Id$" will be replaced with guid of feature. </p>
<p>For a master page, the following metadata will be added via the property tags</p>
<p><Property Name="UIVersion" Value="4" /> </p>
<p><Property Name="ContentTypeId" Value="0x010105" /></p>
<p><Property Name="ContentType" Value="$Resources:cmscore,contenttype_masterpage_name;" /></p>
<p><Property Name="MasterPageDescription" Value="Masterpage for SepulvedaPOC sites." /> </p>
<p>Make sure to edit the description as appropriate.</p>
<p>When the module was created, VS automatically created a feature called "Feature 1". Note that features may also be created by right-clicking "Features" in soln explorer and selecting "Add Feature".</p>
<p>Next step: add event reciever feature activated code if necessary</p>
<p>* Make sure to add the proper modules to the feature
* Make sure that Scope is set to "Site" in the feature if the solution is a sandbox solution</p>
<p>File --> New --> Project</p>
<p>on lefthand side -> Sharepoint -> 2010</p>
<p>usually select an empty template</p>
<p>name the project</p>
<p></p>
<p>to add files, create a module...</p>
<p>right-click project --> add --> new item</p>
<p>select "module"</p>
<p>give the module a name (such as masterpagecatalog)</p>
<p>this will create the module, containing an elements.xml file and open the elements.xml file in code editor. Sample.txt will also be created but may be deleted.</p>
<p>Drag any previously created files that will live in the new module into the module icon in solution explorer</p>
<p>Edit elements.xml. (See example edits to elements.xml in code block further down.) </p>
<p>Edits to make to default xml:</p>
<p>in <Module> tag, put a url (such as Url="_catalogs/masterpage" ) and put RootWebOnly="TRUE"</p>
<p>The <file> tag will also be created with a default url property. Make sure to edit this so that it is correct. By default, it will create a path starting with the name of the module. And if there is no such folder already with that name beneath the Module path, the feature will create one. The actual path is designated by both the <module> url property and the <file> url property (that is, both of those properties are combined).</p>
<p>Add Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" to the <file> elements. IgnoreIfAlreadyExists="TRUE" means "overwrite existing file". Type="GhostableInLibrary" setting is used when a file is placed into a library. If a file is placed outside of a library, Type="Ghostable" would be used.</p>
<p>Change the <file> tags so that it is not self-closing.</p>
<p>Add some Property tags.Columns in the master page correspond to file object properties indicated in the module xml. Other file properties in the xml will also be added to the "property bag" that do not correspond to master page columns (see <property> tags above). </p>
<p>First, it is good practice to always add
<Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/></p>
<p>On compliation, Value="$SharePoint.Feature.Id$" will be replaced with guid of feature. </p>
<p>For a master page, the following metadata will be added via the property tags</p>
<p><Property Name="UIVersion" Value="4" /> </p>
<p><Property Name="ContentTypeId" Value="0x010105" /></p>
<p><Property Name="ContentType" Value="$Resources:cmscore,contenttype_masterpage_name;" /></p>
<p><Property Name="MasterPageDescription" Value="Masterpage for SepulvedaPOC sites." /> </p>
<p>Make sure to edit the description as appropriate.</p>
<p>When the module was created, VS automatically created a feature called "Feature 1". Note that features may also be created by right-clicking "Features" in soln explorer and selecting "Add Feature".</p>
<p>Next step: add event reciever feature activated code if necessary</p>
<p>* Make sure to add the proper modules to the feature
* Make sure that Scope is set to "Site" in the feature if the solution is a sandbox solution</p>
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<!-- ### Example edits to elements.xml ### --> <!--Here is an example of an edited file for a master page...--> <?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Module Name="masterpagecatalog" Url="_catalogs/masterpage" RootWebOnly="TRUE"> <File Path="masterpagecatalog\LLC.master" Url="LLC.master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE"> <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/> <Property Name="UIVersion" Value="4" /> <Property Name="ContentTypeId" Value="0x010105" /> <Property Name="ContentType" Value="$Resources:cmscore,contenttype_masterpage_name;" /> <Property Name="MasterPageDescription" Value="Masterpage for Learning Center." /> </File> </Module> </Elements> <!--And here is an example of an edited file that places files into three different subfolders within the Style Library...--> <?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Module Name="StyleLibrary" Url="Style Library" RootWebOnly="TRUE"> <File Path="StyleLibrary\lilly_main.css" Url="Lilly/lilly_main.css" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" > <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/> </File> <File Path="StyleLibrary\lessons.js" Url="Scripts/lessons.js" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" > <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/> </File> <File Path="StyleLibrary\banner-outlook-rm.jpg" Url="Lilly/images/banner-outlook-rm.jpg" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" > <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/> </File> <File Path="StyleLibrary\bg-persChoiceBottom.jpg" Url="Lilly/images/bg-persChoiceBottom.jpg" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" > <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/> </File> <File Path="StyleLibrary\bg-persChoiceMid.jpg" Url="Lilly/images/bg-persChoiceMid.jpg" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" > <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/> </File> <File Path="StyleLibrary\bg-persChoiceTop.jpg" Url="Lilly/images/bg-persChoiceTop.jpg" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" > <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/> </File> <File Path="StyleLibrary\new-window.png" Url="Lilly/images/new-window.png" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" > <Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/> </File> </Module> </Elements>