-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PackageTool.ps1] Conversion from JSON failed with error: Unterminated string. #197
Comments
Thanks for the report, @LanceMcCarthy. Would you be willing to share out the config file that was generated at As an aside, you can completely skip the "Generating PDP" step. Just don't include the |
Note for maintainers...relevant code for inspection: StoreBroker/StoreBroker/PackageTool.ps1 Lines 363 to 365 in 0fbb6b9
StoreBroker/StoreBroker/Helpers.ps1 Lines 359 to 372 in 0fbb6b9
|
It's not clear to me why this isn't calling |
Thanks @HowardWolosky I made the suggested changes and do not generate a PDP, but the failure still occurs. See https://github.com/LanceMcCarthy/MediaFileManager/runs/980649893?check_suite_focus=true In that same run, I did attempt to output the SBconfig.json contents so I could copy/paste it, but I'm not sure it is even reaching that step because I'm not seeing the output. I will try to upload the file to a blob instead. MetadataYou're right that I dont have any changes to the metadata in this current iteration, but I plan on building it in because that repo is intended as a "gold standard" for dev community to reference for when they want to see a real-world GitHub Action for deploying a WPF/UWP app to both side-load distributions. The step prior to the StoreBroker is my own custom GH Action that uploads the Side Note - Building a new BrokerI am also trying to understand exactly how the API works and what it expects. I'm about 80% done with developing a TypeScript version of the Store Broker that is on npm. Here are the tasks https://github.com/LanceMcCarthy/PartnerCenterBroker/blob/main/src/index.ts I have studied the API docs and understand how complicated the payloads can get (the number of nested objects gets gnarly at times https://github.com/LanceMcCarthy/PartnerCenterBroker/blob/main/src/interfaces.ts) so I like the idea of cloning a previous submission and have done that here https://github.com/LanceMcCarthy/PartnerCenterBroker/blob/36901851ace5126d562ed619a6f3c2446831aa85/src/helpers.ts#L25-L47 . I aim to provide developers with options, no matter what their environment is (at least until PS Core works 100%) |
That's what I would have expected. That suggestion wasn't to fix the problem, I was simply trying to simplify your script; as you indicated below however, that goes against the goal you were trying to achieve.
There is an Azure DevOps task written in TypeScript that you could look at for reference (or use). Something for you to consider: As you might have noticed with this project, there has been minimal activity on the |
Understood, I was just sharing the end result. Thank you for the suggestion as it saves another possible point of failure.
Thank you! Although it seems I should not put too much effort into using the v1 endpoints, but if v2 endpoints aren't public yet my options are limited and might as well keep moving forward with it. I can then do a v2 of my package later. I reviewed the code and I do already have everything they implemented, and more :) What it did show me is that I can simplify the metadata operations and just do the clone+add package and forget about giving the user granular capability to change metadata.
In my initial research, I did find the Partner Center APIs which heavily use the MS Graph, but do not see any endpoints for App submission :( This is why my current efforts are still using Is it going to be NDA Help Although it doesn't sound like you need the testing for v2 of the submission API, but if you do, we can use my MVP NDA for my private Actions 😉 (I would help write day1 blog (similar to my Windows 10 on ARM: Day-One Developer Experience post). I am also under several other TAP programs and have pre-approved clearance for future TAPs/NDAs. This would not only help me, but I can also have working examples for the community ready-to-go. |
@HowardWolosky Okay, I tried making this as simple and straightforward as possible by using all full strings where possible and broke out the steps to different stages to catch where it is failing The Store Broker now seems to hang when trying to generate the SBConfig file (for 26 minutes until the VM quits)
Here are the relevant steps, you can see the offender in Part 2 # ************ PART 1 ************ #
- name: Install Store Broker (SB)
uses: Amadevus/pwsh-script@v1
id: install-store-broker
with:
script: |
# ---- Install StoreBroker
Set-ExecutionPolicy RemoteSigned -Force
git clone https://github.com/Microsoft/StoreBroker.git 'D:\a\MediaFileManager\MediaFileManager\SBGitRoot\'
# ************ PART 2 ************ #
- name: Authenticate SB and Generate SBConfig.json
uses: Amadevus/pwsh-script@v1
id: authenticate-store-brokwer
with:
script: |
$username = $env:PartnerCenterClientId
$password = ConvertTo-SecureString $env:PartnerCenterClientSecret -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($username, $password)
Import-Module -Force 'D:\a\MediaFileManager\MediaFileManager\SBGitRoot\StoreBroker'
# ---- Authenticating with Service Principal Credentials
Set-StoreBrokerAuthentication -TenantId $env:PartnerCenterTenantId -Credential $cred
# ---- Making a new directory for Store Broker generated files
New-Item -Path 'D:\a\MediaFileManager\MediaFileManager\SBTemp' -ItemType Directory
******** GETS STUCK HERE (for 26 minutes) ****************
# ---- Create config file
New-StoreBrokerConfigFile -AppId $env:PartnerCenterStoreId -Path 'D:\a\MediaFileManager\MediaFileManager\SBTemp\SBConfig.json'
# ************ PART 3 (debug step to upload the sbconfig.json file to my blob) ************
- name: Uploading SBconfig.json to Azure Blob (temp)
id: blob-upload-sbconfig
uses: LanceMcCarthy/[email protected]
with:
connection_string: ${{ secrets.AZURE_DVLUP_BLOB_CONNECTION_STRING }}
container_name: general-app-files
source_folder: D:\a\MediaFileManager\MediaFileManager\SBTemp\
destination_folder: SBTemp
# ************ PART 4 do the actual submission ************
- name: Store Broker (Upload the Store build to Microsoft Partner Center)
uses: Amadevus/pwsh-script@v1
id: store-broker-submit-app
with:
script: |
$uploadPackage = "D:\a\MediaFileManager\MediaFileManager\src\MediaFileManager\PackageProject\StoreUploadPackages\PackageProject_" +
$env:UWP_VERSION + "_" + $env:UwpBundlePlatform + "_bundle.appxupload"
$username = $env:PartnerCenterClientId
$password = ConvertTo-SecureString $env:PartnerCenterClientSecret -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($username, $password)
Import-Module -Force 'D:\a\MediaFileManager\MediaFileManager\SBGitRoot\StoreBroker'
# ---- Authenticating with Service Principal Credentials
Set-StoreBrokerAuthentication -TenantId $env:PartnerCenterTenantId -Credential $cred
# ---- Create submissionPackage
New-SubmissionPackage -ConfigPath 'D:\a\MediaFileManager\MediaFileManager\SBTemp\submission.json' -ImagesRootPath 'D:\a\MediaFileManager\MediaFileManager\src\MediaFileManager\PackageProject\Images' -AppxPath $uploadPackage -OutPath 'D:\a\MediaFileManager\MediaFileManager\SBTemp\' -OutName 'submission.json'
# ---- Submitting app, we only want to close last submission and just update package
Update-ApplicationSubmission -ReplacePackages -AppId $env:PartnerCenterStoreId -SubmissionDataPath 'D:\a\MediaFileManager\MediaFileManager\SBTemp\submission.json' -PackagePath $uploadPackage -AutoCommit -Force OutputHere is the out put from step 2 (with repeated lines removed)
Here's the run if you want to see the whole thing https://github.com/LanceMcCarthy/MediaFileManager/runs/982539639?check_suite_focus=true |
Thanks @LanceMcCarthy. I think the easiest way to debug what might be going on is to understand your submission that it's trying to convert into a config file. Can you run the following? $appId = '9PD3JFK7W5MB'
$app = Get-Application -AppId $appId
$sub = Get-ApplicationSubmission -AppId $appId -SubmissionId $($app.lastPublishedApplicationSubmission.id)
$subJsonFilePath = New-TemporaryFile
ConvertTo-Json -InputObject $sub -Depth 20 | Out-File -FilePath $subJsonFilePath
Write-Information -MessageData "Please upload $($subJsonFilePath.FullName) to a new gist at https://gist.github.com/LanceMcCarthy and then reference that gist in microsoft/StoreBroker#197" -InformationAction Continue That would allow us to reproduce the behavior of As an aside, the general usage pattern for StoreBroker would be to generate the config file once and check that in with your source code. Same with the PDP file content. The intention of the config file is two fold:
If you're always generating it fresh, you're not getting any of those benefits. That's fine if that functionality isn't desired, but wanted to make sure that was an explicit decision on your part. And as for the PDP content, like I said before, you'd convert an existing published submission into the individual components (XML and image files) once and then store them with your code, and then update the listing metadata in those files locally when you've made changes to the app that you're intending to publish. Then you'd generate a submission package with the updated PDP content and make use of You may just want to add a comment to that effect (that those command are intended to only be run once when initially configuring StoreBroker). |
It definitely a problem inside the submission data being downloaded from DevCenter. See the latest runs output, even after trying to copy out the data https://github.com/LanceMcCarthy/MediaFileManager/actions/runs/208040011 I'm going to try this on my normal pc and get real files I can include with source control. I'll let you know how that goes tomorrow |
No, that error indicates a poorly formatted config file. That means it already successfully downloaded the data and successfully created a config file. Now it's trying to read and covert the config file back into an object during StoreBroker/StoreBroker/PackageTool.ps1 Lines 3274 to 3276 in 0fbb6b9
Like I said, if you just run the commands in my previous response, I'll be able to see your submission and understand what's going on when the config file is getting created and why it's malformed. |
@HowardWolosky I just couldn't get GitHub actions to cooperate and give me the files, so I did everything locally on my dev machine instead. You can get the generated file here https://dvlup.blob.core.windows.net/ci-cd/broker-output/tmp828.tmp |
@HowardWolosky Discovered the issue! I think I found the culprit. In the notes for certification, I see a SubmissionData.jsonNotice the SBConfig.jsonIf you look at the sbconfig.json, the Source Control-based ConfigAs you recommended, I checked in the config.json and submission.json files into my source. I also moved my Store Broker script into its own ps1 file. https://github.com/LanceMcCarthy/MediaFileManager/tree/main/.scripts. My question now is: If I use the checked-in SubmissionData.json file, how does For example: # Generated (STILL FAILS b/c of BAD CHAR)
$newSubmissionDataPath = Join-Path -Path $sbTempFolderPath -ChildPath 'submissionData.json'
# Checked in with source control and has manually fixed notes
$originalSubmissionDataFilePath = 'D:\a\MediaFileManager\MediaFileManager\.scripts\submissionData.json'
$packagePath = 'D:\a\MediaFileManager\MediaFileManager\src\MediaFileManager\PackageProject\StoreUploadPackages\StoreUploadPackages.zip'
Update-ApplicationSubmission -ReplacePackages -AppId $env:PartnerCenterStoreId -SubmissionDataPath $originalSubmissionDataFilePath -PackagePath $packagePath -AutoCommit -Force
Next StepsAfter multiple attempts to get past this, I think I'm going to submit a new version via DevCenter and clean out the cert notes After that is published, I can generate a new submissionData file for future use. PS - Despite these issues in GitHub Actions (PS core?) StoreBroker is an absolute pleasure in user-mode locally. |
Thanks Lance. I have a fix out now (#198) that fixes that issue and another issue that would have been there due to the URL's in certification notes.
Don't check-in the submission data. Only check-in the config file. You should generate the "submission package" (which outputs a .json and .zip file) each time you want to do a submission. You reference the .json and .zip file in
Thanks for the feedback! If you like StoreBroker, you may be interested in looking at PowerShellForGitHub as well. It's next major release ( |
I was just looking closely at the PR with the fix, good stuff! Now I understand why there were so many comments in the config.json file :D
This is one of the key places that I was misunderstanding, I have read USAGE.md several times, but it gets a little confusing about where the ZIP file comes from. The submission data path is clear because you set the name with To illustrate the question using the snippet below, is the generated ZIP file path
In any case, this thread is not the right place to discuss this, I'll keep trying and open a new Issue if I need to. Here's what I settled on for upcoming builds:
Maybe it will be useful to add a new doc page for complete examples (instead of partial snippets) so the reader can see the use in entirety? This usually helps make everything click (after being taken through the individual steps). I'd be happy to contribute to it with GitHub Actions example. |
Is this planned to merge soon? I noticed you have 2 PRs open. I have an opportunity to try out the Broker again in a workflow because my last manual publish has passed certification (I would like to give the Action a shot for real). |
Done. One PR was for |
There's an error running
Update-ApplicationSubmission -ReplacePackages
regarding notes for certification.I am not making any custom package setup; just a clone of previous submission and uploading new packages with the
-ReplacePackages
flag.Script
Here's my Powershell script, running in a GitHub Action on a windows machine. Disregard any envVars you dont recognize, they're set earlier on the VM.
If you want to see the rest of it, it is public here MediaFileManager CD.yaml.
Output
Here is the output of the run. To keep it short, I removed the duplicate "I'm busy" updates.
However, if you would rather see the entire step's output, it is also public here. Media File Manager - Run 204743631 - Fail.
Be sure to expand the arrows:
The text was updated successfully, but these errors were encountered: