问题
I'm trying to deploy a simple web part to SharePoint 2013 using Visual Studio 2013 and I am getting the following error:
Error occurred in deployment step 'Activate Features': Feature with Id '....' is not installed in this farm, and cannot be added to this scope.
Spent a long time trying to find a solution to this. Several blogs and forums talking about it and giving different solutions (none worked for me).
Feature scope is set to site, and solution is not set to sandbox.
Deployment works if I select the option to skip activation. But then when I go to Site settings and look at features I cannot find it. (I looked at both Site Features and Site Collection Features).
I have tried to change permissions in several different places. I made the user the site owner as well as the site collection administrator (tried both primary and secondary), but it didn't seem to make a difference.
I'm new to the whole complicated world of SharePoint, so bare with my lack of exact terms. Before going for this farm solution I tried with sandbox and everything worked fine: I was able to debug and deploy.
I know there's a way to deploy using PowerShell but I don't think that's the ideal solution here.
Any suggestions? Thanks!
回答1:
if you skip activation you should deploy feature by script.
Steps to deploy a webpart
1 - in the project settings go sharepoint and select "No Activation" for "Active Deployment Configuration"
2 - Deploy the project
3 - Run the code below in management shell (Run as administrator the management shell)
install-spfeature "yourProjectName_FeatureName" /*exp: TEST.Webparts_Feature1*/
4 - Deactivate - activate fature in "Site Collection Features"
来源:https://stackoverflow.com/questions/27851058/error-deploying-visual-web-part-to-sharepoint-2013-activate-features