Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jongalloway/969ca4d2c351c5a37949 to your computer and use it in GitHub Desktop.
Save jongalloway/969ca4d2c351c5a37949 to your computer and use it in GitHub Desktop.
Migrate .NET Projects to Automatic Package Restore (recursive) - more information here:https://weblogs.asp.net/jongalloway/scripting-net-project-migration-to-automatic-nuget-package-restore
#this automates the steps found here: http://docs.nuget.org/docs/workflows/migrating-to-automatic-package-restore
#yes, you could code golf this to about 6 characters if you wanted to
$find= @'
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
'@
foreach ($f in Get-ChildItem -Recurse -Path ".\" -Filter *.csproj | sort-object)
{
$text = Get-Content $f.FullName -Raw
$text.Replace($find, "") | set-content $f.FullName
}
Get-ChildItem .\ -include .nuget,packages -Recurse | foreach ($_) { remove-item $_.fullname -Force -Recurse }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment