Last active
September 25, 2025 10:33
-
-
Save DanTup/a8731542819ed9020d434cd96944bab2 to your computer and use it in GitHub Desktop.
Add Defender exclusions for Dart/Flutter
This file contains hidden or 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
| # This must be run inside an _Administrator_ PowerShell terminal. | |
| # Press Win+X then click "Terminal (Admin)" | |
| # Paths to exclude. | |
| $paths = @( | |
| # Add your development folder(s) here, quoted and followed by commas. | |
| "your dev folder path here", | |
| # Dart Analysis Server cache. | |
| $(if ($env:ANALYZER_STATE_LOCATION_OVERRIDE) { $env:ANALYZER_STATE_LOCATION_OVERRIDE } else { "$env:LOCALAPPDATA\.dartServer" }), | |
| # Pub cache. | |
| $(if ($env:PUB_CACHE) { $env:PUB_CACHE } else { "$env:LOCALAPPDATA\Pub\Cache" }), | |
| # The Dart SDK. | |
| $(if (where.exe dart.exe 2> $null) { $(Split-Path -parent (Split-Path -parent (where.exe dart.exe | Select-Object -First 1))) }), | |
| # The Flutter SDK. | |
| $(if (where.exe flutter.bat 2> $null) { $(Split-Path -parent (Split-Path -parent (where.exe flutter.bat | Select-Object -First 1))) }) | |
| ) | |
| # Remove blanks, duplicates, and non-existent folders. | |
| $paths = $paths | Where-Object { $_ -and (Test-Path -Path $_ -PathType Container) } | Select-Object -Unique | |
| # Add each valid path to Windows Defender's exclusion list. | |
| foreach ($path in $paths) { | |
| Write-Host "Adding exclusion: $path" | |
| Add-MpPreference -ExclusionPath $path | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment