AppSource/Publish-ToAppsource.ps1


function Publish-AppToAppsource {
    Param(
        [Parameter(Mandatory=$true)]
        $authContext,
        [Parameter(Mandatory=$true)]
        [string] $appSourceProductName,
        [Parameter(Mandatory=$true)]
        $appFile,
        [Parameter(Mandatory=$true)]
        $libraryAppFiles,
        [Parameter(Mandatory=$false)]
        [bool] $autoPromote = $false
    )

    Write-Host "##[section] Publish $appSourceProductName"
    Write-Host " - App: " $appFile
    Write-Host " - Libraries: " $libraryAppFiles
    Write-Host " - Auto promote: " $autoPromote

    $appsourceProduct = Get-AppSourceProduct -authContext $authcontext -productName $appSourceProductName -silent

    New-AppSourceSubmission -authContext $authContext -productId $appsourceProduct.id -appFile $appFile -libraryAppFiles $libraryAppFiles -silent -autoPromote:$autoPromote

    $results = Get-AppSourceSubmission -authContext $authContext -productId $appsourceProduct.id
    if ($results.substate -eq 'Failed') {
        throw "Submission failed for $($appsourceProduct.Name)"
    }
} 

Write-Verbose "Function imported: Publish-AppToAppsource"

<#
$publishParams = @{
    authContext = $authContext
    appSourceProductName = 'SMART Core Localization for Ukraine'
    appFile = 'SMART Core Localization for Ukraine' | findAppByNameInFolder($appBasePath)
    libraryAppFiles = 'SMART Core,SMART Helpers' | splitToArray | findAppByNameInFolder($appBasePath)
    autoPromote = $false
}
 
$libArchiveName = 'SMART Core Libraries'
$libZip = Join-Path $appBasePath "$libArchiveName.zip"
$publishParams.libraryAppFiles | Compress-Archive -DestinationPath $libFileName -Force
$publishParams.libraryAppFiles = $libZip
 
Publish-AppToAppsource @publishParams
#>