Provision SharePoint Documents and Assets using wsp package

For provisioning SharePoint assets like documents in a document library can be provisioned using the wsp package. In this article, we will see, how to provision SharePoint assets using C# programmatically using wsp package deployment.

Provision SharePoint Documents and Assets using wsp package


  1. Click on File > New > Project
  2. Select Empty SharePoint Project

  3. Create a new SharePoint 2019 Project. I have created a project with name Asset Provisioning


  4. Specify the Site URL and security level for debugging. Choose to Deploy as a farm solution.

  5. Right-click on Project name > Add > New Item

  6. Add a module to the Project

  7. Create a file folder structure as shown below
  8. When you keep adding files in the Module, Elements.xml file will add the references of files automatically. Make few changes as shown below to add all the files along with folder structure in document library.
    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <Module Name="Module1" Url="SiteAssets">
        <File Path="Module1\Sample.txt" Url="Sample.txt" Type="GhostableInLibrary"/>
        <File Path="Module1\CustomFiles\js\featuredPost.js" Url="CustomFiles/js/featuredPost.js" Type="GhostableInLibrary"/>
        <File Path="Module1\CustomFiles\js\yammer.js" Url="CustomFiles/js/yammer.js" Type="GhostableInLibrary"/>
        <File Path="Module1\CustomFiles\css\CustomStyle.css" Url="CustomFiles/css/CustomStyle.css" Type="GhostableInLibrary"/>
        <File Path="Module1\CustomFiles\css\Sample.css" Url="CustomFiles/css/Sample.css" Type="GhostableInLibrary"/>
        <File Path="Module1\CustomFiles\images\Footer.png" Url="CustomFiles/images/Footer.png" Type="GhostableInLibrary"/>
        <File Path="Module1\CustomFiles\images\logo.png" Url="CustomFiles/images/logo.png" Type="GhostableInLibrary"/>
      </Module>
    </Elements>
  9. In this case we are deploying files to Site Assets librray, therefore Url="SiteAssets".
  10. If you want to deploy custom master pages in Master page gallary, you can use Url="_catalogs/masterpage"
  11. Right-click on the project name and Deploy the solution.
  12. Go to the Site Assets library where you can see your files and folders created.

Post a Comment

0 Comments