Skip to content

Instantly share code, notes, and snippets.

@lennybacon
Last active February 29, 2016 10:06
Show Gist options
  • Save lennybacon/b2296155edff8421f7b5 to your computer and use it in GitHub Desktop.
Save lennybacon/b2296155edff8421f7b5 to your computer and use it in GitHub Desktop.
Batch processing Visual Studio ProjectItems with the Nuget Package Management Powershell Console
function Search-ItemsRecursive($projectItems, $list){
ForEach ($item in $projectItems) {
$itemName = $item.Name
Write-Host "Getting all project items for $itemName"
$list.Add($item);
if($item.ProjectItems -ne $null){
Search-ItemsRecursive -projectItems $item.ProjectItems -list $list
}
if($item.SubProject -ne $null -and $item.SubProject.ProjectItems -ne $null){
Search-ItemsRecursive -projectItems $item.SubProject.ProjectItems -list $list
}
}
}
function Get-AllProjectItems(){
$list = New-Object System.Collections.ArrayList($null);
ForEach ($project in $dte.Solution.Projects) {
$projectName = $project.Name
Write-Host "Getting all project items for $projectName"
Search-ItemsRecursive -projectItems $project.ProjectItems -list $list
}
return $list;
}
$items = Get-AllProjectItems
ForEach ($item in $items) {
if($item.Name -ne $null `
-and $item.Name.EndsWith(".js") `
-and $item.Name.EndsWith(".min.js") -ne $true
){
Write-Host $item.Name;
ForEach ($property in $item.Properties) {
if($property.Name -eq "BuildAction"){
$property.Value = 0
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment