Wednesday, December 30, 2015

SharePoint 2013 List Item Receiver Test and Deploy

Create a test list item event receiver per http://onceinawhilescribble.blogspot.com/2013/05/creating-simple-event-receiver-in.html
hit F5 or debug it to be sure it works as expected.
Deployment:
Right-click project node in Solution Explorer and choose publish.
Follow http://jaxsharepoint.blogspot.com/2013/06/deploying-wsp-to-sharepoint-2013.html and http://sharepoint.stackexchange.com/questions/140592/create-wsp-package-in-visual-studio-2013
to deploy the WSP to local server.


PS C:\Users\user1\Documents> add-spsolution "C:\Users\user1\Documents\SharePointProject1.wsp"

Name                           SolutionId                           Deployed
----                           ----------                           --------
sharepointproject1.wsp         51fbac1e-e23f-4dc4-a8c7-a9190577b206 False


PS C:\Users\user1\Documents> install-spsolution -identity "sharepointproject1.wsp" -gacdeployment
PS C:\Users\user1\Documents>

Verify sharepointproject1.wsp shows as deployed in http://myserver/_admin/Solutions.aspx
Get GUID of new feature, using this method http://iamprogrammerdotnet.blogspot.com/2012/03/enabledisable-feature-sharepoint-2010.html
or rename .wsp to .cab, extract the Feature.xml and copy the guid from the id attribute of the Feature element. Then enable the feature:
PS C:\Users\user1\Documents> enable-spfeature -identity "046347fa-aa0b-4a29-846e-eff84970a4fb" -url http://myserver/sites/teamsitecol1/

Verify it's activated in http://myserver/sites/teamsitecol1/_layouts/15/ManageFeatures.aspx and that it still works by creating new item in DocumentLog when adding item to target list.

In Visual Studio make small change to output that gets added to new list item. Do a "publish" as before. Then update the solution:
PS C:\Users\user1\Documents> update-spsolution -identity "sharepointproject1.wsp" -gacdeployment -literalpath "C:\Users\user1\Documents\sharepointproject1.wsp"
Repeat test and make sure new change is reflected.

Noticed I needed to rename the feature so that it uses a non-default name as shown in http://myserver/sites/teamsitecol1/_layouts/15/ManageFeatures.aspx

In Visual Studio, expand the feature and open the xml file; add an attribute called "Title" e.g. Title="My Feature" to the Feature element.

Then disable the feature in http://myserver/sites/teamsitecol1/_layouts/15/ManageFeatures.aspx and retract the existing solution from the SharePoint 2013 Management Shell:
uninstall-spsolution -identity "sharepointproject1.wsp"
remove-spsolution -identity "sharepointproject1.wsp" -force -confirm:$false

Then redploy as before.

No comments:

Post a Comment