Using Modules to Include Files in the Solution
There may be times when you may want to deploy files to the SharePoint server regardless of their file type, such as new master pages. To do this, you can use Modules (not to be confused with Visual Basic code modules). Modules are containers for files in a SharePoint solution. When the solution is deployed, the files in the module are copied to the specified folders on the SharePoint server.
Module Items and Elements
To create a module, add it to a project by choosing it in the Add New Item dialog box. Then, modify its Elements.xml file to include the names of the files you want to deploy, where they are located on the system, and where they should be copied on the SharePoint server.
Here is an example of the Elements.xml file for a module:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="https://schemas.microsoft.com/sharepoint/">
<Module Name="Module1">
<File Path="Module1\Sample.txt" Url="Module1/Sample.txt" />
</Module>
</Elements>
Newly-created modules contain the following default files:
File Name |
Description |
---|---|
Elements.xml |
The definition file for the module. |
Sample.txt |
A placeholder file that serves as an example of a file in the module. |
The Elements.xml file contains the following elements:
Element Name |
Description |
||||||||
---|---|---|---|---|---|---|---|---|---|
Elements |
Contains all of the elements defined in the module. |
||||||||
Module |
The module element has a single attribute, Name, that specifies the name of the module in the format <Module Name="Module1">. Note If you change the name of the module (or its Folder Name property), you must manually update the name in the Module element. If you specify a subdirectory for the file(s) in the Module element, Windows SharePoint Services (WSS) will automatically create a matching directory structure for them. |
||||||||
File |
The File element has two parameters, Path and Url.
|
Each file that you want to deploy requires a separate <File> element entry in Elements.xml.
See Also
Tasks
How to: Include Files by Using a Module
Other Resources
Developing SharePoint Solutions