1 param($installPath, $toolsPath, $package, $project)
2 
3 $analyzersPaths = Join-Path (Join-Path (Split-Path -Path $toolsPath -Parent) "analyzers" ) * -Resolve
4 
5 foreach($analyzersPath in $analyzersPaths)
6 {
7     # Uninstall the language agnostic analyzers.
8     if (Test-Path $analyzersPath)
9     {
10         foreach ($analyzerFilePath in Get-ChildItem $analyzersPath -Filter *.dll)
11         {
12             if($project.Object.AnalyzerReferences)
13             {
14                 $project.Object.AnalyzerReferences.Remove($analyzerFilePath.FullName)
15             }
16         }
17     }
18 }
19 
20 # $project.Type gives the language name like (C# or VB.NET)
21 $languageFolder = ""
22 if($project.Type -eq "C#")
23 {
24     $languageFolder = "cs"
25 }
26 if($project.Type -eq "VB.NET")
27 {
28     $languageFolder = "vb"
29 }
30 if($languageFolder -eq "")
31 {
32     return
33 }
34 
35 foreach($analyzersPath in $analyzersPaths)
36 {
37     # Uninstall language specific analyzers.
38     $languageAnalyzersPath = join-path $analyzersPath $languageFolder
39     if (Test-Path $languageAnalyzersPath)
40     {
41         foreach ($analyzerFilePath in Get-ChildItem $languageAnalyzersPath -Filter *.dll)
42         {
43             if($project.Object.AnalyzerReferences)
44             {
45                 try
46                 {
47                     $project.Object.AnalyzerReferences.Remove($analyzerFilePath.FullName)
48                 }
49                 catch
50                 {
51 
52                 }
53             }
54         }
55     }
56 }