title: Modify content of .sppkg file before uploading to SPO app catalog using DevOps pipelines
body: <p>I want to run a SPFx web part through DevOps build pipeline once, and have the same artifacts be deployable to any environment.</p>
  <p>Currently I have a setup where there are <strong>#{PlaceHolders}#</strong> in the code which are to be replaced by the Replace Tokens task in a DevOps release pipeline. To do this I have added an Extract activity to unzip the .sppkg package, after which I replace the tokens in the generated .zip file, and then I archive the files back into a .sppkg package.</p>
  <p>The issue I run into is that seemingly, SharePoint doesn't like me tampering with it's .sppkg files. In the app catalog, I get this in the column App Package Error Message whenever I have replaced the tokens:</p>
  <p>The package contains the wrong number of relationships for relationship type <code>'http://schemas.microsoft.com/sharepoint/2012/app/relationships/package-manifest'. Expected: '1'. Actual: '0'.</code></p>
  <p>Any clue on how I can safely modify the .sppkg package is appreciated, or how I otherwise can implement environment variables into my SFPx web parts after the solution is packaged.</p>
  <p>The goal is to being able to promote one and the same build to subsequent environments in Azure DevOps.</p>
  <p><a href="https://i.stack.imgur.com/L5QZE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L5QZE.png" alt="Build promotion" /></a></p>
  <p><strong>Edit providing release pipeline details</strong></p>
  <p>Using the standard Extract files and Archive files tasks, these are the settings used:</p>
  <p>Archive patterns:
  $(System.DefaultWorkingDirectory)/MyProjectFolder/drop/SharePoint/solution/my-package.sppkg</p>
  <p>Destination folder:
  $(System.DefaultWorkingDirectory)/MyProjectFolder/drop/SharePoint/solution/extracts</p>
  <p>Root folder or file to archive:
  $(System.DefaultWorkingDirectory)/MyProjectFolder/drop/sharepoint/solution/extracts</p>
  <p>Archive file to create:
  $(System.DefaultWorkingDirectory)/MyProjectFolder/drop/sharepoint/solution/my-package.sppkg</p>
  <p>Also I tried modifying the .sppkg package locally after also building locally but to the same result. So I'm thinking there might be a signature that gets added to .sppkg packages that's looking for length, and if changed, it might get denied?</p>