sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

SPFx solution with multiple extensions doesn't display all extensions after deployment

Open erwinkehrt opened this issue 6 years ago • 7 comments

Category

  • [x] Bug

Describe the bug

I have an SPFx solution that started out as 1 web part, simple HelloWorld using Yeoman. I deployed that to my tenant app catalog as version 1.0.0.0. I have a communication site that I added this application to. The site has 1 regular SharePoint list and the out of the box shared documents doclib. I added the HelloWorld web part to the home page.

Then I ran the Yeoman generator again and added a list view command set extension. ExtensionOne should only appear on generic lists and only in the command bar. It is a HelloWorld extension. I packaged this up as version 1.0.0.1 and deployed it to my tenant app catalog. I updated the app on my site. At this point the extension shows up on my generic SharePoint list correctly but the web part disappears from the home page.

Finally, I ran the Yeoman generator again and added a second list view command set extension. ExtensionTwo should only appear on document libraries and can appear on both the command bar and the context menu. It is once again a HelloWorld extension. I packaged this up as version 1.0.0.2 and deployed it to my tenant app catalog. I updated the app one more time on my site. Now only ExtensionOne shows up. The original web part is still missing from my home page and ExtensionTwo does now show up at all.

If I delete the app from my site and from my tenant app catalog, empty out the trash bins, empty out the second level trash bins, deploy again, and add the app to my site again, then everything works as expected.

Steps to reproduce

  1. Run Yeoman generator to create HelloWorld web part
  2. Package and deploy to tenant app catalog.
  3. Add app to site.
  4. Add web part to a page.
  5. Run Yeoman generator again and add list view command set extension.
  6. Update app version.
  7. Package and deploy to tenant app catalog.
  8. Update app on site.
  9. Run Yeoman generator again and add another list view command set extension.
  10. Update app version.
  11. Add new extension to elements.xml
  12. Package and deploy to tenant app catalog.
  13. Update app on site.

Expected behavior

I expect my web part to not disappear after first update. I also expect to see my second extension after my second update. It is not feasible to have to completely wipe the app from SharePoint and do a fresh deployment every single time we add a new extension. As shown here, this should be possible.

Developer environment

  • OS: Mac 10.15.3
  • Framework: Node 8.17.0
  • Browser(s): Chrome Version 80.0.3987.149
  • Tooling: VS Code 1.43.2, SPFx v1.10.0
  • SharePoint Online
  • Out of the box communication site

Additional context

I added my code here. This code includes both extensions and the web part. The only things I changed that were not a part of the HelloWorld Yeoman generated files are as follows:

  • package-solution.json: changed the version number
  • elements.xml: added the second extension since Yeoman doesn't automatically do that, made the second extension RegistrationId=101 and Location=ClientSideExtension.ListViewCommandSet as described here
  • ExtensionOneCommandSet.manifest.json in each file: changed the text in the buttons so I know which button belongs to which extension

Thanks for your contribution! Sharing is caring.

erwinkehrt avatar Mar 27 '20 02:03 erwinkehrt

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

msft-github-bot avatar Mar 27 '20 02:03 msft-github-bot

As we have seen that many times in our projects too, I could share some of the solutions we found for getting around that. First, the missing Webpart in the picker: The yeoman generator does not add a feature specification for Webparts to the package-solution.json. We have seen such Webparts working many times, but sometimes they are missing (for whatever reason). What we found is, that when you add a feature for your Webpart to the package-solution.json then it works every time. The object to add looks like this:

     {
        "id": "6eebd686-ad73-44c5-b09b-5ca3db55ff92",
        "title": "A title that will be visible in the website features catalog",
        "description": "A description that will be visible in the website features catalog",
        "version": "1.0.0.1"
      }

The value of "id" must match the id of the Webpart that is defined in the Webpart.manifest.json. It seems, increasing the value of "version" to something higher than "1.0.0.0" helps too, especially if you already had the solution installed without the added feature definition. After that you'll need to create a new package, upload it and update the installed app on the site, like you did before.

Second, the missing extension: You did everything we are also doing in that case with one exception. If the newly added extension does not show up you might need to deactivate and reactivate the feature corresponding to the extension under website features. That should do the trick. It helps to have keywords like "Webpart" and "Extension" in the titles of your features to better distinguish between them when you need to reactivate one.

Hope this helps.

cwdata avatar Mar 27 '20 14:03 cwdata

Thank you, @cwdata. I'll try these ideas out today!

erwinkehrt avatar Mar 29 '20 21:03 erwinkehrt

Hi @cwdata @andrewconnell , I tried out the ideas listed above. Here are my findings:

Regarding the missing webpart in the picker, adding this entry to the package-solution.json file does add an entry to the site features list. I can then turn that feature off and on and can then see the webpart in the picker again.

However, this causes an issue in the app catalog under the column "App Package Error Message." The error is "Component ID {0} exists more than once in current package." From my testing, if the solution is already deployed before I add this to the package-solution.json file, the error doesn't really make a difference. But if I do a fresh deployment of the app with this object in the file, then the app never works correctly and no webparts show up in my picker and no extensions show up where they should.

Regarding the missing extension, turning the extension feature off/on definitely does the trick. Thanks for that suggestion. However, our extensions will be installed on potentially thousands of sites. Therefore we cannot do this process manually. Our next step was to try doing this using PowerShell. But then we hit a roadblock there when enabling the feature.

Apparently you cannot currently enable a site feature that is disabled. There are open bugs on that here and here for example. I tried this with PnP and with the o365 cli tool, same result on both.

Our current best solution is to do a tenant wide deployment and add code to our webparts and extensions so that they only work on the sites that we want them to. We are planning on checking the site property bag for X property and if it does not exist then they will show an error.

While this doesn't really resolve the original bug, if there is something we are doing incorrectly or could be doing better, please do share your ideas! Thank you!

erwinkehrt avatar Apr 13 '20 19:04 erwinkehrt

Hi @erwinkehrt that error you get in the app catalog is a known bug (https://github.com/SharePoint/sp-dev-docs/issues/3802) Currently upgrading a solution in the app catalog is not reliable, and regarding the open issue, won't be in the foreseeable future. You need to delete the package (also from the recycle bin) and upload it again. That's not dependent on having the Webpart feature listed in the package-solution.json. We have seen that error on packages without such a feature too. Fresh deployments with a feature for the Webpart in the Json file work very well for us, as well as upgrades using the app catalog procedure mentioned above. I'm wondering what could make the difference here. Regarding the management of the feature: We always deactivated and reactivated the features through the GUI. I have not tried to automate that yet but yes that is indeed a huge problem if that doesn't work either. If a tenant wide deployment of SPFx solutions that are meant to run only on one or a couple of sites is the only solution, then the load on SharePoint will increase heavily. Hopefully that's going to increase the priority to fix some of the bugs :-)

cwdata avatar Apr 14 '20 08:04 cwdata

Hi @cwdata and whoever might be having this issue in the future. We opened a support ticket for this and were able to find a proper solution to this specific problem.

In regards to the web part disappearing, the solution that @cwdata left on March 27th fixes that.

In regards to the new extensions not displaying after being added to a solution that is already deployed, the trick is updating the version number in the feature itself in the package-solution.json file. This can be a different number than the version number of the solution, but you might as well keep them the same, point is it must be updated when a new extension is added to the solution. Please see image below as an example.

Screen Shot 2020-05-20 at 5 14 14 PM

Once the solution with a new extension and updated feature version number is deployed, assuming this is not a tenant wide deployment, you need to update the installed app on the site in question. For clarity, this is done by going to the site contents, clicking on the ellipsis of the already installed application, click on details. That will take you to a page that should look something like this.

Screen Shot 2020-05-20 at 5 26 56 PM

The "ADD IT" button will be available at this point. Once you add the latest version your extension will be visible. No need to turn the feature off and on.

If you need to do this programmatically like we do, you can use the sharepoint-pnp PowerShell command found here. This is the equivalent of going through the GUI and grabbing the latest application for your site.

The support tech told us they will probably update the official MS documentation to account for this use case; we will see.

Hope this helps!

erwinkehrt avatar May 20 '20 22:05 erwinkehrt

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

msft-github-bot avatar May 28 '20 00:05 msft-github-bot