Last active
May 22, 2019 13:00
-
-
Save glucaci/7c99fec4a63e0e05eef2bd71741a2de3 to your computer and use it in GitHub Desktop.
PowerShell funtion to display all Visual Studio Solution in directory and open specific one
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This function can be places in C:\Users\<YourUser>\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 | |
| function s { | |
| $solutionFiles = Get-ChildItem -Path .\ -Filter *.sln -Recurse | |
| if ($solutionFiles.Count -lt 1) { | |
| Write-Host "Coudn't find any solution file in the current directory." | |
| return | |
| } | |
| if ($solutionFiles.Count -lt 2) { | |
| $solutionNumber = 1 | |
| } | |
| else { | |
| For ($i=1; $i -le $solutionFiles.Count; $i++) { | |
| Write-Host $i $solutionFiles[$i-1].Name | |
| } | |
| $solutionNumber = Read-Host -Prompt 'Select solution to open' | |
| } | |
| $solutionToOpen = $solutionFiles[$solutionNumber - 1] | |
| $fullPath = Join-Path -Path $solutionToOpen.Directory.FullName $solutionToOpen.Name | |
| Write-Output "Opening $fullPath" | |
| Start-Process $fullPath | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment