Wednesday, October 19, 2011

Deploy files to Pages subfolder (SharePoint 2010)

Deploy pages/files to a subfolder in the pages library.

How it’s done:
In Visual Studio 2010 create a module:


with the following elements.xml

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="">
<Module Name="AdminPages" Url="$Resources:osrvcore,List_Pages_UrlName;/AdminPages" Path="AdminPages">
<File Path="ChangePassword.aspx" Url="ChangePassword.aspx" Type="GhostableInLibrary" />
<File Path="ForgotPassword.aspx" Url="ForgotPassword.aspx" Type="GhostableInLibrary" />

Some explanation about the elements file:
Module.Name: name of the module
Module.Url: location in SharePoint, where do you want to deploy the files to.
Module.Path: location of the files in your feature (In this case in VS2010 the ‘AdminPages’ module creates a directory in the feature with name ‘AdminPages’)
File.Path: location of the file in your feature (it also uses the Module.Path, so don’t add the ‘AdminPages’ because it’s defined in the Module.Path)
File.Url: filename in SharePoint (you could name the file whatever you like)
Add the module to a feature.
Deploy the solution.

After installing and activating the feature (that contains the AdminPages module) you will see that a folder ‘AdminPages’ is created in the /Pages (depending on language) folder.