function Test-IsPackageReliableService { <# .SYNOPSIS Returns true if the given package is a Service Fabric Reliable Service. A Reliable Service is a class library that implements Service Fabric's reliable service pattern, as opposed to a topshelf application. If a package ships with Service Fabric Application/Service manifests it is assumed to be a reliable service. #> [CmdletBinding(DefaultParameterSetName = 'FeedQuery')] [OutputType([System.Boolean])] Param( [Parameter(Mandatory=$true, ParameterSetName='FeedQuery')] [string]$FeedSource, [Parameter(Mandatory=$true, ParameterSetName='FeedQuery')] [string]$Name, [Parameter(Mandatory=$true, ParameterSetName='FeedQuery')] [string]$Version, [Parameter(Mandatory=$false, ParameterSetName='FeedQuery')] [PSCredential]$Credential = $null, [Parameter(Mandatory=$true, ParameterSetName='ProvidedPackageFiles')] [object]$PackageFiles ) $loglead = (Get-LogLeadName); if($PSCmdlet.ParameterSetName -eq "FeedQuery") { $PackageFiles = Get-PackageFileList -FeedSource $FeedSource -Name $Name -Version $Version -Credential $Credential; } # Consider the package a reliable service if it contains both an application and a service manifest. # Search for these two files in known locations. # Search for the application manifest. $hasApplicationManifest = $false; foreach ($file in $PackageFiles) { if ($file.fullPath -eq "ApplicationManifest.xml") { $hasApplicationManifest = $true; break; } } # Search for the service manifest. $hasServiceManifest = $false; foreach ($file in $PackageFiles) { if ($file.fullPath -eq "svc/ServiceManifest.xml") { $hasServiceManifest = $true; break; } } # Consider the package a reliable service if it contains the application/service manifests. $isReliableService = $hasApplicationManifest -and $hasServiceManifest; $microText = if($isReliableService) { "is" } else { "is not" }; Write-Verbose "$loglead : Determined that package $Name|$Version $microText a reliable service"; return $isReliableService; }