Created
April 4, 2016 04:41
-
-
Save minidfx/321a94fd5b72492266940b3a4895c06e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function FxCop | |
{ | |
$vsCommonTools = @(${Env:VS140COMNTOOLS}, ${Env:VS120COMNTOOLS}, ${Env:VS110COMNTOOLS}) | |
$fxCopPath = $vsCommonTools | Where { $_ -ne $null -and $_ -ne "" } ` | |
| Select @{ Name = "Out"; Expression = { $_ | Split-Path -Parent | Split-path -Parent } } ` | |
| Select -ExpandProperty "Out" ` | |
| Select @{ Name = "Out"; Expression = { Join-path $_ "Team Tools\Static Analysis Tools\FxCop\FxCopCmd.exe" } } ` | |
| Select -ExpandProperty "Out" ` | |
| Where { $_ | Test-Path } ` | |
| Select -first 1 | |
If ($fxCopPath -eq $null) | |
{ | |
Write-Host "No Visual Studio tools found for the following version: 14, 12, 11" -foreground "Red" | |
Exit 1 | |
} | |
$builPath = "<path>" | |
$files = @("<path>", "<path>") | |
$files | ForEach { If(-not ("$builPath/$_" | Test-Path)) { Write-Host "First build the project before executing FxCop." -foreground "Red"; Exit 3 } } | |
$arguments = @("/forceoutput", | |
"/gac", | |
"/ignoregeneratedcode", | |
"/ruleset:=<path>", | |
"/out:fxcop-result.xml") | |
$files | ForEach { $arguments += "/f:$builPath/$_" } | |
& $fxCopPath $arguments | |
If ($LASTEXITCODE -ne 0) | |
{ | |
Write-Host "An error occurred while validating binaries, please check the fxcop-result.xml file." -foreground "Red" | |
Exit 2 | |
} | |
} | |
Export-ModuleMember -function FxCop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment