-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMicrosoft.Powershell_profile.ps1
More file actions
25 lines (18 loc) · 975 Bytes
/
Microsoft.Powershell_profile.ps1
File metadata and controls
25 lines (18 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$worktreeBase = "$HOME\Documents\git\branch"
$worktreePath = Join-Path $worktreeBase $BranchName
Write-Host "📂 Creating worktree for branch '$BranchName' at '$worktreePath'" -ForegroundColor Cyan
# Run git worktree add
git worktree add -b $BranchName $worktreePath#
Write-Host "✅ Worktree created." -ForegroundColor Green
# Path to Visual Studio (adjust edition if needed: Community / Professional / Enterprise)
$vsPath = "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe"
# Find a .sln file in the new worktree
$sln = Get-ChildItem -Path $worktreePath -Filter *.sln -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1
if ($sln) {
Write-Host "🚀 Opening solution '$($sln.Name)' in Visual Studio..." -ForegroundColor Yellow
& $vsPath $sln.FullName
}
else {
Write-Host "⚠️ No .sln file found in '$worktreePath'" -ForegroundColor Red
}
}