Skip to content
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

v1.1.0 - Create PDP XSD for IAP's, and add New-IapSubmissionPackage #11

Merged
merged 1 commit into from
Jan 26, 2017
Merged

v1.1.0 - Create PDP XSD for IAP's, and add New-IapSubmissionPackage #11

merged 1 commit into from
Jan 26, 2017

Conversation

HowardWolosky
Copy link
Member

  • Added new PDP schema and example file for IAP's and updated the
    corresonding PDP.md documentation.
  • Adds ConvertFrom-ExistingIapSubmission.ps1, mirroring
    ConvertFrom-ExistingSubmission.ps1, to auto-generate the IAP
    PDP set from an existing publishing or pending submission.
  • Added the ability to generate a new IAP StoreBroker configuration
    file based on a default config file, as well as based on a
    current submission for that IAP, similar to what we do for
    applications.
  • Added New-InAppProductSubmissionPackage to generate a StoreBroker
    payload from a config file and IAP PDP's (and optional icons).
  • Updated PackageTool's Resolve-PackageParameters helper method to
    optionally skip a list of parameters so that the same method could
    be used for both packaging commands since they're so similar, even
    though IAP's don't use appx packages.
  • Updated Update-InAppProductSubmission to do a similar iapId check
    of the commandline vs the payload's json value, similar to what we
    do for Update-ApplicationSubmission.
  • Updated SETUP.md and USAGE.md documentation to reflect these changes,
    and removed the note in README.md that this work hasn't been done yet.

Additionally:

  • Fixed telemetry property typos for Iap's (referencing an Iap property
    instead of IapId), along with other AppId->IapId references for the
    IAP methods.
  • Fixed documentation example typo in ConvertFrom-ExistingSubmission.ps1
  • Minor related Comment-Based-Help (CBH) changes to PackageTool.

Resolves #3 : Create PDP XSD for IAP's, and add New-IapSubmissionPackage

@msftclas
Copy link

Hi @HowardWolosky-MSFT, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!


It looks like you're a Microsoft contributor (Howard Wolosky). If you're full-time, we DON'T require a Contribution License Agreement. If you are a vendor, please DO sign the electronic Contribution License Agreement. It will take 2 minutes and there's no faxing! https://cla.microsoft.com.

TTYL, MSBOT;

### Getting Your IapId

The next steps require you to know the IapId for the In-App Product ("add on") that you are trying
to use StoreBroker with.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with StoreBroker

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved.


You can read [PDP.md](PDP.md) for greater detail on PDP files. Right now, we just need to get you
started by generating your IAP's PDP files based on your current published (or pending) submission.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-OutPath

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch. resolved.


2. Once you have the config, review all of the properties at the bottom half of the file.
These are the values for these properties as they are configured for your IAP in the store today.
Some users have realized that the values in the store (and thus in this file) are not what they
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In step 1 you have "the Store" and in step 2 you have "the store". Should be consistent

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed. Fixed all instances to capitalized Store.

expected, so it's worth checking them here and fixing them if need be. (If you do change any of
these properties, you'll need to use the appropriate _switch_ to the `Update-InAppProductSubmission`
later on to make sure that your changes are applied).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could link to the section on using the Update- cmdlets

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

As part of its input, `New-InAppProductSubmissionPackage` expects a configuration file, which
you should have [already created](SETUP.md#getting-your-iap-config).

### IAP Commands
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 588, "there exits an" --> "there exists an"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch. fixed.

* **`<productType>`** is either `Consumable` for a "Developer managed consumable", or
`Durable` for a "durable managed consumable". Please note that at this time, although the
Developer Web Portal supports the creation of "Store Managed Consumables", the Store Submission
API _does not_.
* **`<productId>`** is a unique name that you provide to refer to this IAP in this API and in your
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you order these bullets according to the order they appear in the example command, or alphabetically? Right now it's neither.  Are Consumable/Durable product types well known or explained earlier? If not, it would be helpful to have a link here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good feedback. Re-ordered to match the example, and then added a documentation link to further explain those two product types.

.PARAMETER IapId
The ID of the IAP that the PDP's will be getting created for.
The most recent submission for this IAO will be used unless a SubmissionId is
explicitly specified.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IAO -> IAP

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


# Import Write-Log
$rootDir = Split-Path -Path $PSScriptRoot -Parent
. $rootDir\StoreBroker\Helpers.ps1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes the script isn't moved out of the folder it came in. Do you care to add an existence check for the file?

Copy link
Member Author

@HowardWolosky HowardWolosky Jan 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion. Will do, here and in the other conversion script.

$comment = $Xml.CreateComment(" $iconElementXml ")
$Xml.DocumentElement.RemoveChild($elementNode) | Out-Null
$Xml.DocumentElement.AppendChild($comment ) | Out-Null
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to explain this in the notes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added .NOTES to explain what's going on here.

[string] $FileName
)

$dropFolder = Join-Path $PdpRootPath $Lang
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full parameter names for Join-Path?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


# If there are no images being used at all, then we can also early return
$imageCount = 0;
foreach ($lang in $LangImageNames.GetEnumerator())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: foreach ($lang in $LangImageNames.Values)

unless there is a specific reason you want it this way

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't fix. I think this might be personal opinion here, but I feel like it's more clear what's happening when using the KeyValuePair within the foreach as opposed to just the value.


# Quick analysis to help teams out if they need to do anything special with their PDP's

$seenImages = $LangImageNames[$langs[0].Name]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did $langs come from? I don't see it in this function

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. I missed this when I wrote ConvertFrom-ExistingSubmission.  It's created in Main and is being treated as a global. I'll update the code to get the info directly from $LangImageNames instead.


foreach ($image in $LangImageNames[$langs[$i].Name])
{
if (-not $seenImages.Contains($image))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: -contains operator

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel strongly either way here. Changed.

else
{
$output = @()
$output += "Every language that has a PDP that references the following images:"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra that

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed



# function Main invocation
Main
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No newline at end of file

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

</xs:attribute>
</xs:attributeGroup>

<xs:attributeGroup name="ScreenshotImageGroup">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right-o.  Meant to remove that. Thanks.

// The delimiter and any remaining text on that line will be removed.

{
// New-InAppProductSubmissionPackage parameters
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 space tabs, not 2

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VS had undone that. Fixed.

// to the wrong product when working at the commandline.
//
// Ex: "iapId": "0ABCDEF12345"
"iapId": "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not here, but noticed that the example for "appId" uses "AppId" instead of lowercase.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


"notesForCertification": ""
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no newline at end of file

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


$sub = Get-InAppProductSubmission -IapId $IapId -SubmissionId $submissionId

$updated = $updated -replace '"iapId": "",', "`"iapId`": `"$IapId`","
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like there could be a simple function to do this work. Maybe you won't think it's worth the extra change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't fix. I don't think it's worth the refactoring work in this instance.

$sourcePath = Join-Path -Path $PSScriptRoot -ChildPath $script:defaultIapConfigFileName

# Get-Content returns an array of lines.... using Out-String gives us back the linefeeds.
$template = (Get-Content $sourcePath) | Out-String
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get-Content needs Parameter Names. Also, add -Encoding utf8

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed all instances.

}
catch
{
throw
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why catch at all instead of letting it bubble?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. For some reason, I recall that the behavior with the nested exceptions is that it reported the exception and then continued executing the next line. I just tested it now though, and that didn't happen. Not sure what I was seeing before at this point.

}

Write-Log "Copying (Item: $sourcePath) to (Target: $Path)." -Level Verbose
Set-Content -Path $Path -Value $template -Force
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-Encoding utf8

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed all instances.

@@ -204,7 +382,7 @@ function New-StoreBrokerConfigFile
New-Item -Force -ItemType Directory -Path $dir | Out-Null
}

$sourcePath = Join-Path $PSScriptRoot $script:defaultConfigFileName
$sourcePath = Join-Path -Path $PSScriptRoot -ChildPath $script:defaultConfigFileName

# Get-Content returns an array of lines.... using Out-String gives us back the linefeeds.
$template = (Get-Content $sourcePath) | Out-String
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-Encoding and -Path here too

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed all instances.


.PARAMETER XmlFilePath
A full path to the localized .xml file to be parsed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra space

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

if (Test-Path -Path $imageContainerPath -PathType Container)
{
$image = Get-ChildItem -Recurse -File -Path $imageContainerPath -Include $imageFileName | Select-Object -First 1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would remove this space since it directly relates to the previous line

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

if ($null -eq $image)
{
Write-Log "Could not find image '$($imageFileName)' in any subdirectory of '$imageContainerPath'." -Level Error
throw "Halt Execution"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw elsewhere in this change you are just using "throw". Why use "Halt Execution" here and not there?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't fix: throw by itself should be reserved for within a catch statement -- it means that it will re-throw the exception that was just caught, without altering it.

containing localized data for the app (Title, Description, Icon, etc.)

.EXAMPLE
Convert-ListingsMetadata -PDPRootPath 'C:\PDP\' -PDPInclude 'InAppProductDescription.xml' -ImagesRootPath 'C:\IapIcons'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong cmdlet

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

C:\PDP\language2\...\InAppProductDescription.xml
#>
[CmdletBinding()]
[OutputType([Hashtable])]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we should be consistent about using OutputType.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally fixed all the instances that PSScriptAnalyzer was complaining about. I've opened #14 to track this suggestion.

$submissionRequestBody.listings = Convert-ListingsMetadata @listingsResources
}

$submissionRequestBody = Remove-DeprecatedProperties $submissionRequestBody
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need Parameter Name

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -1340,6 +1874,9 @@ function Resolve-PackageParameters
Hashtable mapping the parameters of New-SubmissionPackage (except for ConfigPath)
to their provided values.

.PARAMETER SkipValidation
An array of parameters that should this method should not attempt to be validate.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rephrase

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

# If either 'PDPRootPath' or 'ImagesRootPath' is present, both must be present
if ((-not [String]::IsNullOrWhiteSpace($ParamMap[$script:s_PDPRootPath])) -xor
(-not [String]::IsNullOrWhiteSpace($ParamMap[$script:s_ImagesRootPath])))
if (($SkipValidation -inotcontains $script:s_PDPRootPath) -and ($SkipValidation -inotcontains $script:s_ImagesRootPath))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-notcontains is case insensitive by default. I'd rather use that much like how we use -like instead of -ilike

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't fix. While I do know that the comparisons are case-insensitive by default, I started getting into the habit of being explicit to improve code readability for those that don't realize that.

* Added new PDP schema and example file for IAP's and updated the
  corresonding PDP.md documentation.
* Adds ConvertFrom-ExistingIapSubmission.ps1, mirroring
  ConvertFrom-ExistingSubmission.ps1, to auto-generate the IAP
  PDP set from an existing publishing or pending submission.
* Added the ability to generate a new IAP StoreBroker configuration
  file based on a default config file, as well as based on a
  current submission for that IAP, similar to what we do for
  applications.
* Added New-InAppProductSubmissionPackage to generate a StoreBroker
  payload from a config file and IAP PDP's (and optional icons).
* Updated PackageTool's Resolve-PackageParameters helper method to
  optionally skip a list of parameters so that the same method could
  be used for both packaging commands since they're so similar, even
  though IAP's don't use appx packages.
* Updated Update-InAppProductSubmission to do a similar iapId check
  of the commandline vs the payload's json value, similar to what we
  do for Update-ApplicationSubmission.
* Updated SETUP.md and USAGE.md documentation to reflect these changes,
  and removed the note in README.md that this work hasn't been done yet.

Additionally:
* Fixed telemetry property typos for Iap's (referencing an Iap property
  instead of IapId), along with other AppId->IapId references for the
  IAP methods.
* Fixed documentation example typo in ConvertFrom-ExistingSubmission.ps1
* Minor related Comment-Based-Help (CBH) changes to PackageTool.
@HowardWolosky HowardWolosky merged commit faa9751 into microsoft:master Jan 26, 2017
@HowardWolosky HowardWolosky deleted the feature/iapLoc branch January 26, 2017 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants