tasks/analysis.tasks.ps1

$hadesVersion = "0.9.2"

task InstallHadesTool {
    Install-DotNetTool -Name hades -Version $hadesVersion
}

task RunHades Version,InstallHadesTool,{
    $baseOutputName = [IO.Path]::GetFileNameWithoutExtension($SolutionToBuild)
    # Ensure we have a fully-qualified path, as this will be needed when uploading on build server
    $hadesXmlOutputFile = Join-Path $here ("/{0}.sbom.xml" -f $baseOutputName)
    $hadesHtmlReportFile = $hadesXmlOutputFile.Replace(".sbom.xml",".sbom.html")
    Write-Verbose "hadesHtmlReportFile: $hadesHtmlReportFile"
    Write-Verbose "hadesXmlOutputFile: $hadesXmlOutputFile"

    exec {
        & dotnet-hades $SolutionToBuild `
                    -v $script:GitVersion.SemVer `
                    --output $hadesXmlOutputFile `
                    --report $hadesHtmlReportFile
    }

    if ($IsAzureDevops) {
        Write-Host "##vso[task.setvariable variable=SbomHtmlReportPath;isoutput=true]$hadesHtmlReportFile"
        Write-Host "##vso[artifact.upload artifactname=SBOM]$hadesHtmlReportFile"
        Write-Host "##vso[artifact.upload artifactname=SBOM]$hadesXmlOutputFile"
    }
}