Last active
December 25, 2015 12:58
-
-
Save eltone/6979834 to your computer and use it in GitHub Desktop.
A hacky script to remove all traces of nuget package restore when run inside a visual studio solution directory.
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
| if(!(Test-Path *.sln)) { | |
| echo ($pwd.Path + " is not a vs solution folder") | |
| } | |
| else { | |
| #remove .nuget folder | |
| Remove-Item .nuget -Recurse | |
| #remove .nuget sln folder | |
| Get-Item *.sln | ForEach-Object { | |
| $c = [System.IO.File]::ReadAllText($_.Fullname) | |
| $c -replace '(?s)Project\("\{2150E333-8FDC-42A3-9474-1A3956D46DE8\}"\) = "\.nuget",.*?EndProjectSection.*?EndProject', "" | | |
| Set-Content $_.FullName | |
| } | |
| #remove package restore from .csproj | |
| Get-Item *\*.csproj | ForEach-Object { | |
| $pc = Get-Content $_ | Where-Object { | |
| $_ -notmatch '<RestorePackages>true</RestorePackages>' -AND $_ -notmatch 'nuget.targets' | |
| } | |
| Set-Content ($_.FullName) $pc | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment