We should get the below message on the right side.
Go to teams.microsoft.com. Select MS Teams and your channel. From the below screenshot, MyFirstTeam is my Team and General is my channel. Click on +.
Please notice it says Version 1 in the welcome message. This concludes the first part of this article to deploy the first web part to the Teams tab.
Update, upgrade or redeploy the changed version of the web part
Let us now see how to change some code and redeploy it to see if our changes are being reflected or not.
Note
For demo purpose, I would just change 'Version 1' in the welcome message to 'Version 2'.
Step 1
Make code changes in your web part. Please note that we are not changing the solution version number here. We are just changing the text in the webpart.ts file which renders HTML.
Step 2 - Build, Bundle, and Package Solution
Use the below three commands one after another. We will get our solution.sppkg under the /sharepoint/solutions folder.
- gulp build
- gulp bundle --ship
- gulp package-solution --ship
Note
This step is mandatory, else your code changes won't be reflected after re-deployment. Please make sure you run this after the code change and before deployment to the app catalog.
Step 3
Redeploy the package to the app catalog (steps already given in the first part of the article, refer to step 2).
Let us try to Sync to Teams.
Select a solution and click on "Sync to Teams". Got error?
When I checked the browser console, it displays the below error for web service which is requesting sync solution to teams.
The first thing which comes to our mind is that it is giving an error because it is installed on the MS Teams. Agreed!
Step 4 - Delete web part from MS Teams
Let us remove it from MS Teams. Go to MS Teams site. Refer to the below screenshot on where to find the Remove button. Click on "Remove".
Once removed, go to the app catalog and try "Sync to Teams" again. You will notice the same error again.
This is because though we just removed the tab from MS Teams channel, MyFirstTeam still has this app installed.
Click on MyFirstTeam in the above screenshot from the breadcrumb.
As in the below screenshot, click on the Apps tab. We can see AllPlatformWebPart app and a delete button. Click on the delete button.
After it is successfully deleted, go to App Catalog again and try "Sync to Teams". Still same error? This is because, though we have deleted it from MyFirstTeam team, it is still available in MS Teams Store of our tenant.
Actual Step 4 - Let us delete from there. On Teams, on the left side bottom, we will find a store icon. Click on it. The below screen would appear.
Once successfully deleted, go again to the app catalog.
Step 5 - Sync to Teams
Click on 'Sync to Teams' and this time, it would be successfully synced to the Teams solution.
Step 6
Add the web part again to MS Teams tab (step 4 of part 1) using the same steps.
Once added successfully, we will see our code changes reflected and an updated web part. Refer to the below screenshot.
Notice how the welcome message in the above web part contains 'Version 2'.
That's it. We have redeployed the updated version of the web part to MS Teams.
Important Note
To remove an App from MS Teams, you can directly remove it from Teams Store. No need to remove from individual MS Teams tabs and Teams. I have added some additional steps because I tried and wanted to share that removing from individual Teams does not resolve the issue of 'Failed to sync to teams' error until it is removed from MS Team store.
Hope this helps. Happy coding!!!