PoshCode Archive  Artifact [d8e9b86d67]

Artifact d8e9b86d67130c33167c39c4502bdce3aa24010f58a61b3bf81813c06415fbf9:

  • File Open-Solution.ps1 — part of check-in [31539d790f] at 2018-06-10 13:15:49 on branch trunk — Open the sln file in the given directory hierarchy. Present a list if there is more than one. (user: George Mauer size: 910)

# encoding: ascii
# api: powershell
# title: Open-Solution
# description: Open the sln file in the given directory hierarchy. Present a list if there is more than one.
# version: 0.1
# type: function
# author: George Mauer
# license: CC0
# function: Open-Solution
# x-poshcode-id: 2790
# x-archived: 2011-07-16T11:25:31
# x-published: 2011-07-13T21:11:00
#
#
function Open-Solution([string]$path = ".") {
  $sln_files = Get-ChildItem $path -Include *.sln -Recurse
  if($sln_files -eq $null) {
    Write-Host "No Solution file found"
    return
  }
  if($sln_files.Count) { # There is more than one
    do {
      Write-Host "Please select file (or Ctrl+C to quit)"
      for($i=0;$i -lt $sln_files.Count;$i=$i+1) { Write-Host "($i) - $($sln_files[$i])" }
      $idx = Read-Host
      $sln = $sln_files[$idx]
    }until($sln)
  }
  else { $sln = $sln_files }
  Invoke-Item $sln
}