Skip to content

Instantly share code, notes, and snippets.

@wwwlicious
Last active December 18, 2015 20:29
Show Gist options
  • Save wwwlicious/5840977 to your computer and use it in GitHub Desktop.
Save wwwlicious/5840977 to your computer and use it in GitHub Desktop.
Creates a VS solution folder if it does not exist when passed a EnvDTE80.Solution2 object and a folder name.
function Add-SolutionFolder {
[CmdletBinding()]
param(
[Parameter(Position=0, Mandatory=$true)]
$solution,
[Parameter(Position=1, Mandatory=$true)]
[string]$folderName
)
$exists = $false
Foreach($project in $solution.Projects) {
if($project.Kind.Equals([EnvDTE80.PROJECTKINDS]::vsProjectKindSolutionFolder))
{
if ($project.Name.Equals($folderName))
{
$exists = $true
}
}
}
if(!$exists) {
# Create the solution folder.
Write-Host "Creating solution folder: ", $folderName
$parentProject = $solution.AddSolutionFolder($folderName)
}
else {
Write-Host "Solution folder already exists: ", $folderName
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment