Skip to content

Commit

Permalink
sdl script revisions (#691)
Browse files Browse the repository at this point in the history
* testing excluding certain files from FxCop

* test for dependencies
  • Loading branch information
TimothyMothra committed Jan 12, 2018
1 parent 10d6d81 commit 1a0b13d
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions SDL/FxCopSetup.ps1
Expand Up @@ -7,13 +7,33 @@ Param(
[string]$fxCopDirectory = (Join-Path -Path (Split-Path -parent (Split-Path -parent (Split-Path -parent $PSCommandPath))) -ChildPath "fxCop")
)

function IsFileDependency {
[CmdletBinding()]
param
(
$file
)
$dependencyFiles | ForEach-Object {
if($file.Name -eq $_) {
return $true;
}
}

return $false;
}

# these are dlls that end up in the bin, but do not belong to us and don't need to be scanned.
$excludedFiles = @();
$dependencyFiles = @("System.Diagnostics.DiagnosticSource.dll");

Write-Host "`nPARAMETERS:";
Write-Host "`tbuildDirectory:" $buildDirectory;
Write-Host "`tfxCopDirectory:" $fxCopDirectory;

$fxCopTargetDir = Join-Path -Path $fxCopDirectory -ChildPath "target";
$fxCopDependenciesDir = Join-Path -Path $fxCopDirectory -ChildPath "dependencies";


$frameworks = @("net45", "net46", "netstandard1.3");

# don't need to clean folder on build server, but is needed for local dev
Expand All @@ -31,9 +51,17 @@ Get-ChildItem -Path $buildDirectory -Recurse -File -Include *.dll, *.pdb |
return;
}

#find matching framework
$frameworks | ForEach-Object {
if($file.Directory -match $_) {
Copy-Item $file.FullName -Destination (New-Item (Join-Path -Path $fxCopDirectory -ChildPath $_) -Type container -Force) -Force;
$framework = $_;

#is this file a dependency
if (IsFileDependency($file)) {
Copy-Item $file.FullName -Destination (New-Item (Join-Path -Path $fxCopDependenciesDir -ChildPath $framework) -Type container -Force) -Force;
} else {
Copy-Item $file.FullName -Destination (New-Item (Join-Path -Path $fxCopTargetDir -ChildPath $framework) -Type container -Force) -Force;
}
}
}
}
Expand All @@ -60,4 +88,5 @@ Get-ChildItem -Path $fxCopDirectory -Recurse -File |
$count++;
}

Write-Host "`nTOTAL FILES:" $count;
Write-Host "`nTOTAL FILES:" $count;

0 comments on commit 1a0b13d

Please sign in to comment.