6

Using SHarePoint 2013, I have done the following in Visual Studio 2013:

  1. New "Empty SharePoint Project"
  2. In the Project, added a new item "List" with a definition and an instance
  3. In the Feature, set the scope to Site (default is Web)
  4. F5
  5. Everything works as expected - the feature is Site Collection scoped, and the list instance is automatically created in the root of the Site Collection.

However, when trying to do this manually instead (as on a production server):

  1. Publish the Project to a .wsp
  2. Add-SPSolution on the .wsp
  3. Install-SPSolution -GACDeployment -WebApplication http://mysharepoint/

In this case, Install-SPSolution gives the following error:

Install-SPSolution : This solution contains no resources scoped for a Web application and cannot be deployed to a particular Web application.

If I remove -WebApplication, the solution can be installed, but the result is that the solution is deployed globally, the Feature becomes Web scoped, and everything is just generally wrong.

All we want is a Site Collection scoped list instance and list definition that is created in the Site Collection root on activation. So the questions that arise are:

  • Why does F5 work, when Install-SPSolution does not?
  • What magic does F5 do that cannot be done with a manual install?
  • What are we doing wrong?
  • Is there something wrong with a Site Collection scoped list definition and/or list instance? If so, why does F5 allow it?

1 Answer 1

1

You have set the scope of the feature to site level so you don't need the -WebApplication. Solutions with no WebApplication scoped features will be deployed globally this is the normal behavior. The Enable-SPFeature cmdlet is what you would use to activate the feature at the site collection level by specifying the -Url parameter.

Check out MSDN - Elements by Scope to see what feature elements are deployed to what scope (the page is for 2010 but should still apply for 2013).

F5 will simply do an add, install, then activate the feature on the specified site. The feature should still be site collection scoped when added and enabled using PowerShell. You can confirm this via the UI, go to Site Settings and under Site Collection Administration select Site Collection Features if you see the feature here it is site collection scoped.

3
  • But this is a list instance (and a list definition). It makes no sense for this to be global - I want the list instance provisioned to the root of the Site Collection in which the feature is activated!
    – MerdePoint
    Commented Jun 30, 2014 at 7:14
  • There is a difference between the feature and the solution. The solution is what is globally deployed, this just means that the feature in the solution will be available to any site collection. The feature itself is provisioned when you activate it for a site collection. This allows for the features in the solution to be available for new site collections that you create after the solution has been installed. Commented Jun 30, 2014 at 9:38
  • If you only want this list definition be available on the RootWeb, then set the Scope of the feature to Web. Declare list definition and list instance inside this feature and active it only on the RootWeb. This way list instance will be created only on the RootWeb and list definition will only be visible on the RootWeb. Commented Jul 3, 2014 at 20:04

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.