Remove folder & files from project using NuGet/Powershell Remove folder & files from project using NuGet/Powershell powershell powershell

Remove folder & files from project using NuGet/Powershell


Ok, I'm absolutely sure there's a better way than this, but I've never used NuGet or Powershell until today... :/

I just ran this in my Package Manager Console:

$DTE.Solution.Projects | ForEach { $_.ProjectItems | ForEach { if ($_.Name -eq "Controllers") { $_.Remove() } } }

It looped through all projects items looking for a top-level item called "Controllers" and then removed it from the project. Pretty sure you could just change this to "App_Code".

Edit: Friend of mine (who knows a little more Powershell than me) sent this:

$DTE.Solution.Projects|Select-Object -Expand ProjectItems|Where-Object{$_.Name -eq 'Controllers'}|ForEach-Object{$_.Remove()}