This blog post will show you how to set up a custom action in SourceTree that will search your repository for a Visual Studio Solution File and then immediately open that file in Visual Studio.
Here is a screenshot showing it in action:
The implementation is actually a very simple Powershell script that searches for solution files and launches the first one it finds:
param ([string] $repository)
if ($repository) {
$solutionFile = Get-ChildItem -Path $repository -Recurse -Filter *.sln | Select-Object -first 1
if ($solutionFile) {
Start-Process $solutionFile.FullName
}
}
It also helps to have a batch file to launch the Powershell script:
@echo off
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0sourcetree-open-repository.ps1" %1
Setting it up is easy:
sourcetree-open-repository.ps1
sourcetree-open-repository.cmd
Open in Visual Studio
$REPO
I hope you find this information useful.