1

We have added a VS module and foll. is the elements.xml:-

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="Module1" Url="Shared Documents" RootWebOnly="True" Path="Module1" >
    <File Url="Sample.txt" Type="GhostableInLibrary"/>
  </Module>
</Elements>

Since RootWebOnly=true, the file gets deployed only to the RootWeb. Now, if we remove this, then, still the file gets deployed only to root web.

  1. How to deploy this to all webs in the sitecollection?

  2. If we set url to http://serverurl:port/subsite and set RootWebOnly="True", then the file is not deployed anywhere. If we set set RootWebOnly="False", then also the file is not deployed any where.

  3. If we set url to http://serverurl:port/ and set RootWebOnly="True" or "False", then the file is deployed to root web.

1 Answer 1

2

Modules with RootWebOnly="TRUE" will only deploy the files to the Rootweb of the Site Collection and it requires that the feature is Site scoped.

If you try to deploy a module with the RootWebOnly="TRUE" property to a Web then it won't work as SharePoint expects the target to be of SPSite and not SPWeb.

Thus your attempt to deploy the file to url http://serverurl:port/subsite will not work, unless you remove the RootWebOnly property and make the feature Web scoped (though I think the scope won't matter in this case, but for good order's sake make it Web scoped).

So to answer your question How to deploy this to all webs in the sitecollection?:

  • Set the feature deploying the module to Web scoped.
  • Remove the RootWebOnly property from the <Module /> or set it to FALSE.
  • Make sure that all webs in the site collection have a document library named "Shared Documents".
4
  • 1. What about the siteURL, does it matter whether it is root site or subsite? Also, 2. Is the SiteURL VS deployment specific and independent of the powershell deployment?
    – variable
    Commented Apr 28, 2014 at 12:28
  • @variable Yes the site url matters. Set the site url for deployment to be your site collection url http://serverurl:port/. When the feature then gets deployed, if it Web scoped all sites (webs) in the site collection will be affected.
    – user2536
    Commented Apr 28, 2014 at 12:30
  • I also notice that when I follow your method, then, for every subsite I have to manually activate the feature. Is there a way to make this automatic? Also please answer my Q2 in comment1
    – variable
    Commented Apr 28, 2014 at 12:33
  • @variable To answer your Q2: Yes it is deployment specific and independent of powershell deployment. To active the feature on all webs you can make a powershell script that loops through all webs in the site collection and activate the feature. Another approach, which only works when deploying through VS, is to open your solutions properties, go to the SharePoint tab and in the dropdown Active Deployment Configuration select Default.
    – user2536
    Commented Apr 28, 2014 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.