pnp / PnP-Sites-Core

Microsoft 365 Dev PnP Core component (.NET) targeted for increasing developer productivity with CSOM based solutions.
Other
416 stars 643 forks source link

AppPackageIdToken doesn't always resolve on .sppkg name #2101

Open YannickRe opened 5 years ago

YannickRe commented 5 years ago

Category

[X] Bug [ ] Enhancement

Environment

[X] Office 365 / SharePoint Online [ ] SharePoint 2016 [ ] SharePoint 2013

Expected or Desired Behavior

Adding an action to install a solution, using the AppPackageId token with the packagename (eg. pnp-react-search-refiners.sppkg), should install the solution from the tenant app catalog.

Observed Behavior

Error returns that a GUID is expected to have 32 characters with dashes. It only works by providing the title of the package "PnP - Search Web Parts".

Steps to Reproduce

  1. Add a sppkg to the tenant app catalog, don't deploy globally
  2. Create a provisioning template that installs the solution:
      <pnp:ApplicationLifecycleManagement>
        <pnp:Apps>
          <pnp:App AppId="{AppPackageId:pnp-react-search-refiners.sppkg}" Action="Install" />
        </pnp:Apps>
      </pnp:ApplicationLifecycleManagement>
  3. Apply template. Notice this fails.
  4. Adjust template to use the title of the Package (which can be found in the app catalog):
      <pnp:ApplicationLifecycleManagement>
        <pnp:Apps>
          <pnp:App AppId="{AppPackageId:PnP - Search Web Parts}" Action="Install" />
        </pnp:Apps>
      </pnp:ApplicationLifecycleManagement>
  5. Apply template. Notice this works.

Code

I suspect the difference in behavior comes from the fact that the tokens get collected differently. This specific use case only has code to add the title as a valid token: https://github.com/SharePoint/PnP-Sites-Core/blob/19d82e1821b13b50b7546ea35b871956a422a4a2/Core/OfficeDevPnP.Core/Framework/Provisioning/ObjectHandlers/TokenParser.cs#L404)

The other case also adds the filename: https://github.com/SharePoint/PnP-Sites-Core/blob/19d82e1821b13b50b7546ea35b871956a422a4a2/Core/OfficeDevPnP.Core/Framework/Provisioning/ObjectHandlers/Utilities/TenantHelper.cs#L124-L125

SteveClements commented 5 years ago

I notice the same behavior. So, should we just use title going forwards rather than file name?

YannickRe commented 5 years ago

I switched to Title for now, but I don’t really like it. I’m still hoping for a reaction, at least I’ll know if it’s worth my time to try and fix it myself 😀

phillipharding commented 4 years ago

As of the 2020/02 release this is still an issue, using the package filename would be preferable