diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-04-11 20:32:00 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-04-11 20:32:00 -0400 |
commit | b9bc1a6d17cafa0a97b46ffecda432cfc2f23b51 (patch) | |
tree | 319498e8724137a5680186645ca8324f2949eba3 /src/SMAPI.ModBuildConfig.Analyzer/tools/uninstall.ps1 | |
parent | 46141a7af21a921284bc82d49d888da864887d6e (diff) | |
parent | 2d47e479a5e48a575db3ca9998653c0435419440 (diff) | |
download | SMAPI-b9bc1a6d17cafa0a97b46ffecda432cfc2f23b51.tar.gz SMAPI-b9bc1a6d17cafa0a97b46ffecda432cfc2f23b51.tar.bz2 SMAPI-b9bc1a6d17cafa0a97b46ffecda432cfc2f23b51.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI.ModBuildConfig.Analyzer/tools/uninstall.ps1')
-rw-r--r-- | src/SMAPI.ModBuildConfig.Analyzer/tools/uninstall.ps1 | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/SMAPI.ModBuildConfig.Analyzer/tools/uninstall.ps1 b/src/SMAPI.ModBuildConfig.Analyzer/tools/uninstall.ps1 new file mode 100644 index 00000000..4bed3337 --- /dev/null +++ b/src/SMAPI.ModBuildConfig.Analyzer/tools/uninstall.ps1 @@ -0,0 +1,65 @@ +param($installPath, $toolsPath, $package, $project) + +if($project.Object.SupportsPackageDependencyResolution) +{ + if($project.Object.SupportsPackageDependencyResolution()) + { + # Do not uninstall analyzers via uninstall.ps1, instead let the project system handle it. + return + } +} + +$analyzersPaths = Join-Path (Join-Path (Split-Path -Path $toolsPath -Parent) "analyzers") * -Resolve + +foreach($analyzersPath in $analyzersPaths) +{ + # Uninstall the language agnostic analyzers. + if (Test-Path $analyzersPath) + { + foreach ($analyzerFilePath in Get-ChildItem -Path "$analyzersPath\*.dll" -Exclude *.resources.dll) + { + if($project.Object.AnalyzerReferences) + { + $project.Object.AnalyzerReferences.Remove($analyzerFilePath.FullName) + } + } + } +} + +# $project.Type gives the language name like (C# or VB.NET) +$languageFolder = "" +if($project.Type -eq "C#") +{ + $languageFolder = "cs" +} +if($project.Type -eq "VB.NET") +{ + $languageFolder = "vb" +} +if($languageFolder -eq "") +{ + return +} + +foreach($analyzersPath in $analyzersPaths) +{ + # Uninstall language specific analyzers. + $languageAnalyzersPath = join-path $analyzersPath $languageFolder + if (Test-Path $languageAnalyzersPath) + { + foreach ($analyzerFilePath in Get-ChildItem -Path "$languageAnalyzersPath\*.dll" -Exclude *.resources.dll) + { + if($project.Object.AnalyzerReferences) + { + try + { + $project.Object.AnalyzerReferences.Remove($analyzerFilePath.FullName) + } + catch + { + + } + } + } + } +} |