TotalALM / VSTS-Tasks

35 stars 23 forks source link

WildCard specification for Build directory parameter #27

Closed decapent closed 6 years ago

decapent commented 7 years ago

I have a solution with several project within who are following the same nomenclature.

Is there a way to achieve the following nomenclature in order to track all bin folders ?

Your help is very appreciated

rohrerb commented 6 years ago

This would need to be implemented at VSTS level. VSTS converts it to a absolute path at which i search in that directory.

Have you tried to add multiple tasks or using a directory up and having it iterate through all sub directories?

decapent commented 6 years ago

That is what I achieved in the end. Not far from the original custom task, i simply iterate over every projects that needs analysis, build the specific argument string and run FXCop against it.

<#######################################
    Script's main entry point
########################################>
$FxCopEXE = Resolve-FxCopPath
$ruleSets = Resolve-RuleSetsPath
$xslFileTemplate = Resolve-XSLFileTemplate

$projectsToAnalyse = Resolve-ProjectsToAnalyse -buildDirectoryPath $buildDirectory
$buildConfiguration = $buildDirectory.Split("\") | Select-Object -Last 1

# Build FxCop Argument string for each project under analysis
$projectsToAnalyse | ForEach-Object {

    $allArgs =  @()
    $projectName = $_.BaseName
    $binariesLocation = Join-Path $_.FullName "bin\$buildConfiguration"

    $dll = Get-ChildItem -Path $binariesLocation | Where-Object { $_.Name -eq "$projectName.exe" -or $_.Name -eq "$projectName.dll" }
    if($dll) {
        Write-Host "Resolved assembly to analyse --> $($dll.FullName)"
        $allArgs += "/file:$($dll.FullName)"
    }

    $allArgs += "/ruleset:+$ruleSets\$ruleSet.ruleset"
    if ($includeSummary) {
        $allArgs += "/Summary" 
    }

    $allArgs += "/out:$outputFile"

    if ($logging) {
        $allArgs += "/verbose"
    }

    $checkXsl = CheckFileDirectory -path $xslFileTemplate
    if ($checkXsl) {
        $allArgs += "/outXsl:$xslFileTemplate"
        $allArgs += "/applyoutXsl"
    }

    # Invoke Code Analysis tool with proper arguments
    & $FxCopEXE $allArgs
}